From 005755edcdc332315ba077598d4746ac195b069e Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期一, 14 十月 2024 11:45:56 +0800 Subject: [PATCH] increase KPLC KBus from 2 client to 16 clients --- ComLib/Src/functions.c | 333 +++++++++++++++++++ KPLC/Inc/main.h | 26 + Radio_LLCC68/Inc/BoardType.h | 2 ComLib/Inc/SpiFlash.h | 0 ComLib/Inc/BSP.h | 4 ComLib/Inc/functions.h | 5 KPLC/Src/main.c | 266 ++++++++++++++ KSingleLineBus/Listings/demo.m51 | 24 FirmwareTool.exe | 0 KSingleLineBus/Objects/main.obj | 0 KPLC/Inc/BoardType.h | 2 KSingleLineBus/Objects/demo.hex | 175 ++++++++++ KNet.uvmpw | 4 KSingleLineBus/Objects/demo | 0 ComLib/Src/BSP.c | 104 +++++ MDK-ARM/KPLC_C8T6_简易PLC.uvprojx | 25 + ComLib/Src/SpiFlash.c | 3 KPLC/Src/BoardType.c | 2 18 files changed, 940 insertions(+), 35 deletions(-) diff --git a/ComLib/Inc/BSP.h b/ComLib/Inc/BSP.h index 7c75136..221a7b1 100644 --- a/ComLib/Inc/BSP.h +++ b/ComLib/Inc/BSP.h @@ -16,6 +16,7 @@ #include "stm32f0xx_ll_utils.h" #include "stm32f0xx_ll_pwr.h" #include "stm32f0xx_ll_tim.h" +#include "stm32f0xx_ll_i2c.h" void SystemClock_Config(void); void MX_IWDG_Init(void); @@ -26,7 +27,8 @@ void MX_TIM6_Init(void); void MX_SPI1_Init(void); void MX_SPI2_Init(void); - +void MX_I2C1_Init(void); +void Soft_I2C1_Init(void); void MX_ADC_Init(void); #endif /* __BSP__ */ diff --git a/ComLib/Inc/SpiFlash.h b/ComLib/Inc/SpiFlash.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ComLib/Inc/SpiFlash.h diff --git a/ComLib/Inc/functions.h b/ComLib/Inc/functions.h index 14efe32..aaf82bc 100644 --- a/ComLib/Inc/functions.h +++ b/ComLib/Inc/functions.h @@ -62,7 +62,8 @@ void TriggerPendSV(void); void PendSvCallBack(void); void SPI1_IRQ_CallBack(void); - +void DelayUs(int nUs); +void Delay100nS(int n100nS); void Uart1SendDone(void); void Uart1RecvDone(void); void Uart2SendDone(void); @@ -95,4 +96,6 @@ void displayInput(unsigned int cc); void PutOutputSPI1(unsigned int Y); +uint16_t SPI_Flash_ReadID(void); + #endif /* __MYFUNCTIONS_H__ */ diff --git a/ComLib/Src/BSP.c b/ComLib/Src/BSP.c index d7ba5f9..048467f 100644 --- a/ComLib/Src/BSP.c +++ b/ComLib/Src/BSP.c @@ -395,20 +395,28 @@ // GPIO_InitStruct.Alternate = LL_GPIO_AF_0; // LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + GPIO_InitStruct.Pin = LL_GPIO_PIN_15; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; + GPIO_InitStruct.Alternate = LL_GPIO_AF_0; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); /**SPI1 GPIO Configuration PB3 ------> SPI1_SCK PB4 ------> SPI1_MISO PB5 ------> SPI1_MOSI */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; + GPIO_InitStruct.Pin = LL_GPIO_PIN_3 | LL_GPIO_PIN_4 | LL_GPIO_PIN_5; GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; GPIO_InitStruct.Alternate = LL_GPIO_AF_0; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - +/* GPIO_InitStruct.Pin = LL_GPIO_PIN_4; GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; @@ -424,7 +432,7 @@ GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; GPIO_InitStruct.Alternate = LL_GPIO_AF_0; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - +*/ /* SPI1 interrupt Init */ NVIC_SetPriority(SPI1_IRQn, 0); // NVIC_EnableIRQ(SPI1_IRQn); @@ -586,6 +594,88 @@ /* USER CODE END SPI2_Init 2 */ } +void Soft_I2C1_Init(void) +{ + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); + /**I2C1 GPIO Configuration + PB6 ------> I2C1_SCL + PB7 ------> I2C1_SDA + */ + LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_6|LL_GPIO_PIN_7); + GPIO_InitStruct.Pin = LL_GPIO_PIN_6 | LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_6 | LL_GPIO_PIN_7); + +} + +/** + * @brief I2C1 Initialization Function + * @param None + * @retval None + */ +void MX_I2C1_Init(void) +{ + + /* USER CODE BEGIN I2C1_Init 0 */ + + /* USER CODE END I2C1_Init 0 */ + + LL_I2C_InitTypeDef I2C_InitStruct = {0}; + + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); + /**I2C1 GPIO Configuration + PB8 ------> I2C1_SCL + PB9 ------> I2C1_SDA + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_8; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; + GPIO_InitStruct.Alternate = LL_GPIO_AF_1; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = LL_GPIO_PIN_9; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; + GPIO_InitStruct.Alternate = LL_GPIO_AF_1; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C1); + + /* USER CODE BEGIN I2C1_Init 1 */ + + /* USER CODE END I2C1_Init 1 */ + /** I2C Initialization + */ + LL_I2C_DisableOwnAddress2(I2C1); + LL_I2C_DisableGeneralCall(I2C1); + LL_I2C_EnableClockStretching(I2C1); + I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; + I2C_InitStruct.Timing = 0x20303E5D; + I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; + I2C_InitStruct.DigitalFilter = 0; + I2C_InitStruct.OwnAddress1 = 0; + I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; + I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; + LL_I2C_Init(I2C1, &I2C_InitStruct); + LL_I2C_EnableAutoEndMode(I2C1); + LL_I2C_SetOwnAddress2(I2C1, 0, LL_I2C_OWNADDRESS2_NOMASK); + /* USER CODE BEGIN I2C1_Init 2 */ + + /* USER CODE END I2C1_Init 2 */ + +} /* USART1 init function */ void MX_USART1_UART_Init(void) @@ -831,7 +921,11 @@ LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15; -#elif (BOARD_TYPE==9 || BOARD_TYPE==10 || BOARD_TYPE==15 || BOARD_TYPE == 16 ) +#elif (BOARD_TYPE==9 || BOARD_TYPE==10) + GPIO_InitStruct.Pin = LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10| + LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15; + +#elif (BOARD_TYPE==15 || BOARD_TYPE == 16 ) GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7| LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10| diff --git a/ComLib/Src/SpiFlash.c b/ComLib/Src/SpiFlash.c new file mode 100644 index 0000000..3a1d0e8 --- /dev/null +++ b/ComLib/Src/SpiFlash.c @@ -0,0 +1,3 @@ +#include "spiFlash.h" + + diff --git a/ComLib/Src/functions.c b/ComLib/Src/functions.c index 4bca226..534de72 100644 --- a/ComLib/Src/functions.c +++ b/ComLib/Src/functions.c @@ -287,6 +287,14 @@ __nop(); } } +void Delay100nS(int n100nS) +{ + for (int i=0;i<n100nS;i++) + for (volatile int j=0;j<1;j++) + { + __nop(); + } +} int Uart2RecvDMA(void * pBuf, int nSize) { @@ -981,3 +989,328 @@ STRCLK1_1(); __enable_irq(); } + + +#define W25X_WriteEnable 0x06 +#define W25X_WriteDisable 0x04 +#define W25X_ReadStatusReg 0x05 +#define W25X_ReadStatusReg2 0x35 +#define W25X_WriteStatusReg 0x01 +#define W25X_ReadData 0x03 +#define W25X_FastReadData 0x0B +#define W25X_FastReadDual 0x3B +#define W25X_PageProgram 0x02 +#define W25X_BlockErase 0xD8 +#define W25X_SectorErase 0x20 +#define W25X_ChipErase 0xC7 +#define W25X_PowerDown 0xB9 +#define W25X_ReleasePowerDown 0xAB +#define W25X_DeviceID 0xAB +#define W25X_ManufactDeviceID 0x90 +#define W25X_JedecDeviceID 0x9F +#define W25X_ReadUniqueID 0x4B + + +//W25X??/Q?????? +//W25Q80 ID 0XEF13 +//W25Q16 ID 0XEF14 +//W25Q32 ID 0XEF15 +//W25Q32 ID 0XEF16 +#define W25Q80 0XEF13 +#define W25Q16 0XEF14 +#define W25Q32 0XEF15 +#define W25Q64 0XEF16 +//????? +#define SPI_FLASH_CS PAout[15] //??FLASH,???????PB12? +#define SPI_CS_EN LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_15) +#define SPI_CS_NA LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_15) + + + +uint8_t SPI_Tranceive8(uint16_t Y) +{ + int i=0; + while (LL_SPI_IsActiveFlag_TXE(SPI2) == RESET){ DelayUs(1);i++; if (i>320) break; } + LL_SPI_TransmitData8(SPI2,Y>>8); + i=0; + while (LL_SPI_IsActiveFlag_BSY(SPI2) == SET) { DelayUs(1);i++; if (i>320) break;} + i=0; + while (LL_SPI_IsActiveFlag_RXNE(SPI2) == RESET) { DelayUs(1);i++; if (i>320) break;} + Y = LL_SPI_ReceiveData8(SPI2); + return Y; +} + +uint8_t SPI_Transmit(uint8_t * tData, uint8_t nLen, uint8_t timeout) +{ + for (int i=0;i<nLen;i++) { + SPI_Tranceive8(tData[i]); + } + return 0; +} + +uint8_t SPI_TransmitReceive(uint8_t * tData, uint8_t * rData, uint8_t nLen, uint8_t timeout) +{ + for (int i=0;i<nLen;i++) { + rData[i] = SPI_Tranceive8(tData[i]); + } + return 0; +} + + +uint8_t SPI_Flash_ReadSR(void) +{ +uint8_t Data1[2]= {W25X_ReadStatusReg,0x00}; +uint8_t Rxdata[2]; +uint8_t byte=0; + SPI_CS_EN; + SPI_TransmitReceive(Data1,Rxdata,2,100); + SPI_CS_NA; + byte=Rxdata[1]; +return byte; +} +void SPI_Flash_Wait_Busy(void) +{ + while((SPI_Flash_ReadSR()&0x01)==0x01); // ??BUSY??? +} + +void SPI_FLASH_Write_SR(uint8_t sr) +{ +uint8_t Data1[2]= {W25X_ReadStatusReg,0x00}; + Data1[1]=sr; + SPI_CS_EN; + SPI_Transmit(Data1,2,100); + SPI_CS_NA; + } + +uint16_t SPI_Flash_ReadID(void) +{ + uint16_t Temp = 0; + uint8_t Data1[4] = {W25X_ManufactDeviceID,0x00,0x00,0x00}; + uint8_t Data2[2]= {0x00,0x00}; + uint8_t Rxdata[2]; + SPI_CS_EN; + SPI_Transmit(Data1,4,100); + SPI_TransmitReceive(Data2,Rxdata,2,100); + SPI_CS_NA; + Temp=(Rxdata[0]<<8)|Rxdata[1]; +return Temp; +} +uint64_t SPI_Flash_ReadUID(uint8_t * Uid) +{ + union + { + uint64_t Temp; + uint32_t temp2[2]; + uint8_t Rxdata[8]; + }uids; + + uint8_t Data1[5] = {W25X_ReadUniqueID,0x00,0x00,0x00,0x00}; + uint8_t Data2[8]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + SPI_CS_EN; + SPI_Transmit(Data1,5,100); + SPI_TransmitReceive(Data2,uids.Rxdata,8,100); + SPI_CS_NA; + memcpy(Uid,uids.Rxdata,8); + uint32_t t1 = __rev(uids.temp2[0]); + uids.temp2[0]= __rev(uids.temp2[1]); + uids.temp2[1]=t1; +return uids.Temp; +} + +void SPI_FLASH_Write_Enable(void) +{ + uint8_t Txdata[2]={W25X_WriteEnable}; + SPI_CS_EN; + SPI_Transmit(Txdata,1,100); + SPI_CS_NA; +} + +void SPI_FLASH_Write_Disable(void) +{ + uint8_t Txdata[2]={W25X_WriteDisable}; + SPI_CS_EN; + SPI_Transmit(Txdata,1,100); + SPI_CS_NA; +} +void W25QXX_Erase_Sector(uint32_t Dst_Addr) +{ +//??falsh????,??? + + Dst_Addr*=4096; + uint8_t Data1[4] = {W25X_SectorErase,0x00,0x00,0x00}; + Data1[1]=Dst_Addr>>16; + Data1[2]=Dst_Addr>>8; + Data1[3]=Dst_Addr; + SPI_FLASH_Write_Enable(); //SET WEL ,??? + SPI_Flash_Wait_Busy(); + + SPI_CS_EN; + SPI_Transmit(Data1,4,100); + SPI_CS_NA; + SPI_Flash_Wait_Busy(); //?????? + } +void W25QXX_Read(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead) +{ + uint16_t i; + uint8_t Data1[4] = {W25X_ReadData,0x00,0x00,0x00}; + uint8_t Data2[16]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; + + Data1[1]=ReadAddr>>16; + Data1[2]=ReadAddr>>8; + Data1[3]=ReadAddr; + + SPI_CS_EN; + SPI_Transmit(Data1,4,100); +// HAL_SPI_TransmitReceive(&hspi1,pBuffer,pBuffer,NumByteToRead,10); +// HAL_SPI_TransmitReceive_DMA(&hspi1,pBuffer,pBuffer,NumByteToRead); + SPI_TransmitReceive(pBuffer,pBuffer,NumByteToRead,100); +/* + for(i=0;i<NumByteToRead/16;i++) + { + HAL_SPI_TransmitReceive(&hspi1,Data2,pBuffer+i*16,16,100); + } + if (NumByteToRead%16) + { + HAL_SPI_TransmitReceive(&hspi1,Data2,pBuffer+i*16,NumByteToRead%16,100); + } + */ + SPI_CS_NA; +} +void W25QXX_Write_Page(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite) +{ + uint8_t Data1[4] = {W25X_PageProgram,0x00,0x00,0x00}; + + Data1[1]=WriteAddr>>16; + Data1[2]=WriteAddr>>8; + Data1[3]=WriteAddr; + + SPI_FLASH_Write_Enable(); //SET WEL ,??? + SPI_Flash_Wait_Busy(); + SPI_CS_EN; + SPI_Transmit(Data1,4,100); + SPI_Transmit(pBuffer,NumByteToWrite,100); + SPI_CS_NA; + SPI_Flash_Wait_Busy(); //?????? +} +/* +int flash_func(int argc, char * argv[]) +{ + char str1[128]; + int len1; + uint8_t databuf[4096]; + if (argc<=1) + { + len1=sprintf(str1," id uid sr en dis read speed er write write2\r\n");fputstr(str1,len1,0); + }else if (argc>=2) + { + if (strcmp(argv[1],"id")==0) + { + uint16_t flashid; + flashid=SPI_Flash_ReadID(); + len1=sprintf(str1,"Readid %4X \r\n",flashid); + fputstr(str1,len1,0); + + } else if (strcmp(argv[1],"sr")==0) + { + uint8_t flashsr; + flashsr=SPI_Flash_ReadSR(); + len1=sprintf(str1,"Readsr %2X \r\n",flashsr); + fputstr(str1,len1,0); + } else if (strcmp(argv[1],"uid")==0) + { + uint8_t Uid[8]; + uint64_t uid; + uid=SPI_Flash_ReadUID(Uid); + len1=sprintf(str1,"Uid %016llX %02X%02X%02X%02X%02X%02X%02X%02X \r\n",uid,Uid[0],Uid[1],Uid[2],Uid[3],Uid[4],Uid[5],Uid[6],Uid[7]); + fputstr(str1,len1,0); + } else if (strcmp(argv[1],"en")==0) + { + SPI_FLASH_Write_Enable(); + len1=sprintf(str1,"Write Enable \r\n"); + fputstr(str1,len1,0); + } else if (strcmp(argv[1],"dis")==0) + { + SPI_FLASH_Write_Disable(); + len1=sprintf(str1,"Write Disable \r\n"); + fputstr(str1,len1,0); + }else if (strcmp(argv[1],"read")==0) + { + len1=0; + uint32_t addr=0; + if (argc>=3) addr=atoi(argv[2]); + uint16_t datalens=256; + len1=sprintf(str1,"Read Flash %08X for %d bytes \r\n",addr,datalens); + fputstr(str1,len1,0); + W25QXX_Read(databuf,addr,datalens); + for (int i=0;i<16;i++) + { + len1=sprintf(str1,"%2X: ",i); + for (int j=0;j<16;j++) + { + len1+=sprintf(str1+len1," %2X",databuf[i*16+j]); + } + len1+=sprintf(str1+len1,"\r\n"); + fputstr(str1,len1,0); + } + }else if (strcmp(argv[1],"speed")==0) + { + len1=0; + uint32_t addr=0; + if (argc>=3) addr=atoi(argv[2]); + uint16_t datalens=4096; + int times=1000; + len1=sprintf(str1,"Read Flash speed test for %d bytes %d times\r\n",datalens,times); + fputstr(str1,len1,0); + int time1=HAL_GetTick(); + for (int i=0;i<times;i++) + { + addr=i*4096; + W25QXX_Read(databuf,addr,datalens); + } + int time2=HAL_GetTick(); + int deltime=time2-time1; + if (deltime < 1) {deltime =1;} + len1=sprintf(str1,"%d mS %dK/s \r\n",deltime,datalens*times/deltime); + fputstr(str1,len1,0); + + }else if (strcmp(argv[1],"er")==0) + { + uint32_t addr=0; + if (argc>=3) addr=atoi(argv[2]); + W25QXX_Erase_Sector(addr); + len1=sprintf(str1," erase %d\r\n",addr); + fputstr(str1,len1,0); + } else if (strcmp(argv[1],"write")==0) + { + uint32_t addr=0; + if (argc>=3) addr=atoi(argv[2]); + uint16_t datalens=256; + uint8_t value; + if (argc>=4) + { + value=atoi(argv[3]); + for(int i=0;i<256;i++) {databuf[i]=value;} + }else for(int i=0;i<256;i++) {databuf[i]=i;} + W25QXX_Write_Page(databuf,addr,datalens); + len1=sprintf(str1," write %06X for %d bytes\r\n",addr,datalens); + fputstr(str1,len1,0); + } else if (strcmp(argv[1],"write2")==0) + { + uint32_t addr=0; + if (argc>=3) addr=atoi(argv[2]); + uint16_t datalens=256; + for(int i=0;i<256;i++) {databuf[i]=0;} + W25QXX_Write_Page(databuf,addr,datalens); + len1=sprintf(str1," write %06X for %d bytes\r\n",addr,datalens); + fputstr(str1,len1,0); } + else + { + len1=sprintf(str1,"unknown %s \r\n",argv[1]); + fputstr(str1,len1,0); + } + + } + return 0; +} +*/ + diff --git a/FirmwareTool.exe b/FirmwareTool.exe new file mode 100644 index 0000000..1a7cee9 --- /dev/null +++ b/FirmwareTool.exe Binary files differ diff --git a/KNet.uvmpw b/KNet.uvmpw index 7b392e7..b06b4c2 100644 --- a/KNet.uvmpw +++ b/KNet.uvmpw @@ -17,6 +17,8 @@ <project> <PathAndName>.\MDK-ARM\KPLC_C8T6_绠�鏄揚LC.uvprojx</PathAndName> + <NodeIsActive>1</NodeIsActive> + <NodeIsExpanded>1</NodeIsExpanded> </project> <project> @@ -29,8 +31,6 @@ <project> <PathAndName>.\MDK-ARM\KMini_New_CCT6.uvprojx</PathAndName> - <NodeIsActive>1</NodeIsActive> - <NodeIsExpanded>1</NodeIsExpanded> </project> <project> diff --git a/KPLC/Inc/BoardType.h b/KPLC/Inc/BoardType.h index d1f0a4c..1e584f3 100644 --- a/KPLC/Inc/BoardType.h +++ b/KPLC/Inc/BoardType.h @@ -43,7 +43,7 @@ }; -#define BOARD_TYPE 7 +#define BOARD_TYPE 9 #define BOARD_VER 1 #define ENABLE_PLC 1 diff --git a/KPLC/Inc/main.h b/KPLC/Inc/main.h index 81823cb..44f8e1e 100644 --- a/KPLC/Inc/main.h +++ b/KPLC/Inc/main.h @@ -77,6 +77,32 @@ #include "KBus.h" extern stKBusDef KBus1; + +#define Uart1RxBufSize 256 +#define RX2BUFSIZE 64 +#define TX2BUFSIZE 64 +#define DefaultUart1Baud 115200 +#define DefaultUart2Baud 1000000 +#define AlterUart2Baud 500000 + +extern volatile char Uart1BaudGot; +extern volatile char Uart1BaudFirstGot; + +extern unsigned char Uart1Mode; +extern unsigned int Uart1Baud; +extern unsigned int Uart2Baud; + +extern volatile int PendSvCount; + +extern unsigned char Uart1RxBuf1[Uart1RxBufSize]; +extern unsigned char Uart1TxBuf1[260]; + +extern unsigned char Uart2RxBuf1[RX2BUFSIZE]; +extern unsigned char Uart2TxBuf1[TX2BUFSIZE]; + +extern unsigned short Uart1RxBuf1DataLen; +extern unsigned short Uart2RxBuf1DataLen; + /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/KPLC/Src/BoardType.c b/KPLC/Src/BoardType.c index 27abde5..542cccc 100644 --- a/KPLC/Src/BoardType.c +++ b/KPLC/Src/BoardType.c @@ -12,7 +12,7 @@ extern int Region$$Table$$Limit; #define MAKE_VER(x,y) ((x<<8)|y) -#define APP_VER MAKE_VER(1,15) +#define APP_VER MAKE_VER(1,16) const stAppInfoBlock AppInfoBlock __attribute__((at(APPINFOBLOCK_ADDR))) = { diff --git a/KPLC/Src/main.c b/KPLC/Src/main.c index d77ca74..3a16726 100644 --- a/KPLC/Src/main.c +++ b/KPLC/Src/main.c @@ -79,6 +79,31 @@ unsigned char Uart2RxBuf[RX2BUFSIZE]; unsigned char Uart2TxBuf[TX2BUFSIZE]; +unsigned char Uart1RxBuf1[Uart1RxBufSize]; +unsigned char Uart1TxBuf1[260]; + +unsigned char Uart2RxBuf1[RX2BUFSIZE]; +unsigned char Uart2TxBuf1[TX2BUFSIZE]; + +unsigned short Uart1RxBuf1DataLen = 0; +unsigned short Uart2RxBuf1DataLen = 0; + +unsigned char Uart1Mode = 1; //Uart1宸ヤ綔妯″紡锛� 0 : 鏅�氾紝 1 : 閫忎紶妯″紡 + +unsigned int Uart1Baud = DefaultUart1Baud; +unsigned int Uart2Baud = DefaultUart2Baud; + +//unsigned char Uart1RecvBuf1[Uart1RecvBufSize]; +//unsigned short Uart1RecvBuf1DataLen=0; + +//unsigned char Uart2RecvBuf1[128]; +//unsigned short Uart2RecvBuf1DataLen=0; + +volatile char Uart1BaudGot=0; +volatile char Uart1BaudFirstGot=0; +volatile char Uart1DmaInts=0; + + unsigned char SlowFlicker=0; unsigned char FastFlicker=0; @@ -107,6 +132,183 @@ /* USER CODE END PFP */ /* USER CODE BEGIN 0 */ +#define SET_SCL LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_6) +#define CLR_SCL LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_6) +#define GET_SCL LL_GPIO_IsInputPinSet(GPIOB,LL_GPIO_PIN_6) +#define SET_SDA LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_7) +#define CLR_SDA LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_7) +#define GET_SDA LL_GPIO_IsInputPinSet(GPIOB,LL_GPIO_PIN_7) + + +void soft_i2c_start() +{ + SET_SDA; + SET_SCL; + Delay100nS(1); + CLR_SDA; + Delay100nS(1); + CLR_SCL; + Delay100nS(1); +} +void soft_i2c_stop() +{ + CLR_SDA; + Delay100nS(1); + SET_SCL; + Delay100nS(1); + SET_SDA; + Delay100nS(1); +} +void soft_i2c_send8(int nData) +{ + int mask; + mask = 0x80; + for (int j=0;j<8;j++) + { + if (nData & mask) {SET_SDA;} + else {CLR_SDA;} + Delay100nS(1); + SET_SCL; + mask>>=1; + Delay100nS(1); + CLR_SCL; + } + return; +} + +uint8_t soft_i2c_recv8() +{ + unsigned char nData=0; + for (int j=0;j<8;j++) + { + nData <<=1; + Delay100nS(1); + SET_SCL; + nData |= GET_SDA; + Delay100nS(1); + CLR_SCL; + } + return nData; +} + +void soft_i2c_send_ack() +{ + CLR_SDA; + Delay100nS(2); + SET_SCL; + Delay100nS(2); + CLR_SCL; + SET_SDA; + Delay100nS(2); + +} + +void soft_i2c_send_nack() +{ + SET_SDA; + Delay100nS(1); + SET_SCL; + Delay100nS(1); + CLR_SCL; + Delay100nS(1); + SET_SDA; +} +uint8_t soft_i2c_wait_ack(int nTime) +{ + SET_SDA; // Open Drain; + Delay100nS(1); + SET_SCL; + for (int j=0;j<nTime;j++){ + Delay100nS(1); + if (GET_SDA == 0) break; + if (j==nTime-1) return 0; + } + CLR_SCL; + return 1; +} +uint8_t soft_i2c_check_addr(uint8_t Addr) +{ + uint8_t res=0; + soft_i2c_start(); + // Send Device Addr 7bit; + soft_i2c_send8(Addr); + if (soft_i2c_wait_ack(10)) {res=1;} + //Stop + soft_i2c_stop(); +// */ + return res; + +} +uint8_t soft_i2c_read_len( uint8_t Addr , uint8_t Reg, uint8_t len,uint8_t *buf) +{ + int res=0; + //Start + soft_i2c_start(); + // Send Device Addr 7bit; + soft_i2c_send8(Addr &0xfe); + // wait Ack; + if (!soft_i2c_wait_ack(1000)) {soft_i2c_stop();return 1;} + CLR_SCL; + // Send Reg Addr 8bit; + soft_i2c_send8(Reg); + if (!soft_i2c_wait_ack(1000)) {soft_i2c_stop();return 2;} + //Start + soft_i2c_start(); + // Send Device Addr 7bit; + soft_i2c_send8(Addr | 1); + if (!soft_i2c_wait_ack(1000)) {soft_i2c_stop();return 3;} + +// /* + // Recv Data(s) n * 8bit; + SET_SDA; // Open Drain; + for (int i=0;i<len;i++) + { + // recv 1 data 8bit; + unsigned char nData = 0; + nData = soft_i2c_recv8(); + buf[i]=nData; + // Send ACK / NACK; + if (i != len -1) { //ACK + soft_i2c_send_ack(); + } else { // NACK + soft_i2c_send_nack(); + } + } + + //Stop + soft_i2c_stop(); +// */ + return res; +} + +uint8_t soft_i2c_write_len(uint8_t Addr , uint8_t Reg, uint8_t len, uint8_t *buf) +{ + int res=0; + //Start + soft_i2c_start(); + // Send Device Addr 7bit; + soft_i2c_send8(Addr &0xfe); + // wait Ack; + if (!soft_i2c_wait_ack(1000)) return 1; + CLR_SCL; + // Send Reg Addr 8bit; + soft_i2c_send8(Reg); + if (!soft_i2c_wait_ack(1000)) return 2; + for (int i=0;i<len;i++) + { + // send 1 data 8bit; + unsigned char nData = buf[i]; + soft_i2c_send8(nData); + // wait Ack; + if (!soft_i2c_wait_ack(1000)) {res = 5; break;} + } + //Stop + soft_i2c_stop(); + return res; + +} + + int HexToInt(char ch) { @@ -148,10 +350,10 @@ #endif if (Uart2Stat.bPacketRecved) { - KBusParsePacket(&KBus1, (pKBPacket)Uart2RecvBuf1, Uart2RecvBuf1DataLen); - Uart2RecvBuf1DataLen=0; + KBusParsePacket(&KBus1, (pKBPacket)Uart2RxBuf1, Uart2RxBuf1DataLen); + Uart2RxBuf1DataLen=0; Uart2Stat.bPacketRecved=0; - Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1)); + Uart2RecvDMA(Uart2RxBuf1,sizeof(Uart2RxBuf1)); KMem.WDT[2]++; } } @@ -180,12 +382,22 @@ break; case KBusEvDataUpdate: if (KBus1.bMaster) { - KMem.WLX[0]=KBusMem.WLX[0]; //KPLC with KBus Master - KBusMem.WLY[0]=KMem.WLY[0]; + for (int i=0;i<16;i++) + { + KMem.WLX[i]=KBusMem.WLX[i]; //KPLC with KBus Master + KBusMem.WLY[i]=KMem.WLY[i]; + } } else if (KBus1.bSlave) { KMem.WLX[0]=KBusMem.WLY[0]; //KPLC with KBus Slave KBusMem.WLX[0]=KMem.WLY[0]; + KMem.WLX[1]=KBusMem.WLY[1]; //KPLC with KBus Slave + KBusMem.WLX[1]=KMem.WLY[1]; + KMem.WLX[2]=KBusMem.WLY[2]; //KPLC with KBus Slave + KBusMem.WLX[2]=KMem.WLY[2]; + KMem.WLX[3]=KBusMem.WLY[3]; //KPLC with KBus Slave + KBusMem.WLX[3]=KMem.WLY[3]; } + break; case KBusEvCmdResponse: break; @@ -306,10 +518,36 @@ Uart1Baud = DefaultUart1Baud; MX_USART1_UART_Init(); MX_USART2_UART_Init(); - MX_SPI1_Init(); LL_SPI_EnableIT_RXNE(SPI1); +/* + // MX_I2C1_Init(); + Soft_I2C1_Init(); + unsigned char buf1[10] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa}; + unsigned char buf2[10]; +// KMem.WDB[80] = soft_i2c_read_len(0xa0,0x00,8,buf2); +// for (int i=0;i<8;i++){ +// buf2[i]+=1; +// } +// soft_i2c_write_len (0xa0,0x00,8,buf2); +// DelayUs(500); +// KMem.WDB[80] = soft_i2c_read_len(0xa0,0x00,8,&KMem.WDB[81]); +// DelayUs(500); +// KMem.WDB[90] = soft_i2c_read_len(0xa0,0x00,8,&KMem.WDB[91]); + + int nPos = 80; + int nCount =0; + for (int i=0;i<256;i++) + { + if (soft_i2c_check_addr(i)){ + KMem.WDB[nPos + 1 + nCount ] = i; + nCount+=1; + } + DelayUs(10); + } + KMem.WDB[nPos] = nCount; +*/ #if (BOARD_TYPE == 14) // MX_SPI2_Init(); // MX_ADC_Init(); @@ -317,7 +555,7 @@ MX_SPI2_Init(); MX_ADC_Init(); #endif - + MX_IWDG_Init(); MX_TIM6_Init(); @@ -329,7 +567,7 @@ LL_USART_EnableIT_TC(USART1); // LL_USART_EnableIT_RXNE(USART2); - Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1)); + Uart2RecvDMA(Uart2RxBuf1,sizeof(Uart2RxBuf1)); LL_USART_EnableIT_IDLE(USART2); LL_USART_EnableIT_TC(USART2); #if (BOARD_TYPE == 13) @@ -350,6 +588,9 @@ // LL_USART_SetAutoBaudRateMode(USART2, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE); } //LL_USART_EnableIT_TXE(USART1); + +// KMem.WDT[50] = SPI_Flash_ReadID(); + /* USER CODE END 2 */ @@ -395,6 +636,7 @@ KWireLessInit(KMem.EffJumperSW&0x20,KMem.EffJumperSW&0x0f); KWireLessStart(); #endif + while (1) { @@ -635,15 +877,15 @@ // memcpy(&KMem.SDT[64+nSize/2],&KBusChnStats[2],nSize); // for (int i=0;i<128;i++) { SDT[i]=i; } // SDT[48]=55; - if (Uart1RecvBuf1DataLen >0 && Uart1Stat.bPacketRecved) + if (Uart1RxBuf1DataLen >0 && Uart1Stat.bPacketRecved) { int res1 = -1; - res1 = ModBusSlaveParsePkg(1, Uart1RecvBuf1, Uart1RecvBuf1DataLen); + res1 = ModBusSlaveParsePkg(1, Uart1RxBuf1, Uart1RxBuf1DataLen); if (res1 !=0) { - KLParsePacket(1, Uart1RecvBuf1, Uart1RecvBuf1DataLen); + KLParsePacket(1, Uart1RxBuf1, Uart1RxBuf1DataLen); } - Uart1RecvBuf1DataLen=0; + Uart1RxBuf1DataLen=0; Uart1Stat.bPacketRecved=0; Uart1IdelTimer = 0; }else { diff --git a/KSingleLineBus/Listings/demo.m51 b/KSingleLineBus/Listings/demo.m51 index 8cf5390..33015e0 100644 --- a/KSingleLineBus/Listings/demo.m51 +++ b/KSingleLineBus/Listings/demo.m51 @@ -1,4 +1,4 @@ -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 1 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 1 BL51 BANKED LINKER/LOCATER V6.22, INVOKED BY: @@ -59,7 +59,7 @@ CODE 000BH 0003H ABSOLUTE CODE 000EH 0009H UNIT ?PR?_MODBUSPARSEPACKET?MODBUS CODE 0017H 0001H UNIT ?PR?TIMER0_ISR?MAIN -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 2 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 2 CODE 0018H 0001H UNIT ?PR?TIMER1_ISR?MAIN @@ -119,7 +119,7 @@ ?PR?_UART3SENDPACKET?MAIN 0009H 0003H ?PR?_SLPINIT?SLP 0009H 0006H -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 3 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 3 @@ -179,7 +179,7 @@ C:0642H LINE# 134 C:0643H LINE# 135 C:0644H LINE# 136 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 4 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 4 C:0646H LINE# 185 @@ -239,7 +239,7 @@ C:08AAH PUBLIC _Delay_us C:0876H PUBLIC Uart1RecvPacket D:00AFH PUBLIC IE2 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 5 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 5 C:07EDH PUBLIC Uart3RecvPacket @@ -299,7 +299,7 @@ C:08A6H LINE# 201 C:08A9H LINE# 203 ------- ENDPROC UART3INIT -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 6 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 6 ------- PROC UART3_ISR @@ -359,7 +359,7 @@ C:07E7H LINE# 303 C:07E9H LINE# 304 C:07ECH LINE# 305 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 7 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 7 ------- ENDPROC _UART3SENDPACKET @@ -419,7 +419,7 @@ C:074FH LINE# 369 C:074FH LINE# 371 C:0752H LINE# 374 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 8 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 8 C:0755H LINE# 376 @@ -479,7 +479,7 @@ C:0856H LINE# 14 ------- ENDPROC _SLPBCC ------- PROC _SLPINIT -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 9 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 9 D:0009H SYMBOL pSLP @@ -539,7 +539,7 @@ C:0428H LINE# 62 C:0445H LINE# 65 C:0470H LINE# 66 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 10 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 10 C:0470H LINE# 67 @@ -599,7 +599,7 @@ C:057AH LINE# 121 C:057AH LINE# 122 C:057AH LINE# 123 -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 11 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 11 ------- ENDPROC _SLPPROCESS @@ -659,7 +659,7 @@ C:01EDH PUBLIC ?C?PLDOPTR ------- ENDMOD ?C?PLDOPTR -BL51 BANKED LINKER/LOCATER V6.22 06/13/2024 13:47:31 PAGE 12 +BL51 BANKED LINKER/LOCATER V6.22 09/23/2024 09:07:48 PAGE 12 ------- MODULE ?C?PSTOPTR diff --git a/KSingleLineBus/Objects/demo b/KSingleLineBus/Objects/demo index 900a275..c7c4c0a 100644 --- a/KSingleLineBus/Objects/demo +++ b/KSingleLineBus/Objects/demo Binary files differ diff --git a/KSingleLineBus/Objects/demo.hex b/KSingleLineBus/Objects/demo.hex new file mode 100644 index 0000000..2b1c32d --- /dev/null +++ b/KSingleLineBus/Objects/demo.hex @@ -0,0 +1,175 @@ +:03000000020640B5 +:0C064000787FE4F6D8FD75815C02068727 +:1008BD00015900014400015A00014500025B00008E +:1008AA00EF1FAA0670011E4A60087D051DED60F063 +:0208BA0080FAC2 +:0108BC002219 +:03000B00020017D9 +:0100170032B6 +:03001B00020018C8 +:0100180032B5 +:1008910075AC1043AC4043D10275D5A075D4FF436C +:0908A100D10843BA0243AF08225A +:03008B0002001E52 +:10001E00C0E0C0D075D000C000E5AC30E01653ACE7 +:10002E00FE7451255AF8A6ADE55AC3940750020541 +:10003E005A754500E5AC30E10553ACFDC201D00068 +:05004E00D0D0D0E0322B +:10081200E4F594F593F592F5917596FFF595F5B299 +:10082200F5B1F5B4F5B3F5CAF5C9F5CCF5CBF5E2FA +:03083200F5E122CB +:05000300E580F4FF227E +:030008008FA022A4 +:0607C7008B098A0A890B70 +:1007CD00E4FFEFC39D50182001FDAB09AA0AA90B48 +:0F07DD008F827583001200A7F5ADD2010F80E364 +:0107EC0022EA +:1007ED00E545C394025003054522B2C6750C00754C +:1007FD000D00750E51855A0F7B007A00792112027A +:05080D00D4E4F55A22BD +:10087600E544C394025003054422B2C67B007A00C5 +:0B0886007949AD5912000EE4F559222B +:0100190022C4 +:1006CC00A2B6B3E4335401FFAE09EE54FE4FF50964 +:1006DC00A2B7B3E433540125E0FFAE09EE54FD4F4D +:1006EC00F509A2C1B3E433540125E025E0FFAE09BE +:1006FC00EE54FB4FF509A2C2B3E433540133333348 +:10070C0054F8FFAE09EE54F74FF509A2C3B3E43326 +:10071C005401C454F0FFAE09EE54EF4FF509A2C4D6 +:10072C00B3E4335401C43354E0FFAE09EE54DF4F4D +:10073C00F509AF09EF54BFF509AF09EF547FF5097F +:02074C00AF09F3 +:01074E002288 +:10074F00858308120812120891D2ACD2AF1206CCD0 +:10075F008F48AF48EFC4135401F546E548540FF5E1 +:10076F0047750CFF750D07750EC77B007A00792151 +:10077F001200538546218547221200038F48854872 +:10078F0023B2C61207ED7B007A007921120471E5BE +:10079F00416004C2C58002D2C5AF241200081208FE +:1007AF007612001A1200197F647E001208AA055CE7 +:0807BF00E55C70C5055B80C11B +:060835008B168A178918DA +:10083B00E4FFFEEEC39D5013AB16AA17A9188E82C8 +:0B084B007583001200A72FFF0E80E84D +:01085600227F +:100053008B098A0A890B90001DE4F5F01201C09008 +:100063000021E4F5F01201C0AB0CAA0DA90EC003E8 +:10007300C002C001AB09AA0AA90B90001812021D05 +:01008300225A +:100857008B198A1A891BAB1CAA1DA91EC003C002CB +:0F086700C001AB19AA1AA91B90001812021D227A +:0602D4008B098A0A890B68 +:1002DA00AB0CAA0DA90E8B108A118912E50F6404C2 +:1002EA006003020470E50F14FD120835AB10AA1161 +:1002FA00A9129000031200A76F6003020470AB09F1 +:10030A00AA0AA90B12008E7003020394AB10AA1159 +:10031A00A91212008E6469705FAB09AA0AA90B9030 +:10032A0000041200A7FFAB10AA11A9129000011233 +:10033A0000A76F7043AB09AA0AA90B900017041211 +:10034A00011990001DE4F5F01201C0AB10AA11A921 +:10035A00129000021200A7FFAB09AA0AA90B90008B +:10036A00041200A7FD7C00E92405F9E43AFAE92D14 +:10037A00F9EC3AFAEF120107AB09AA0AA90B9000A5 +:10038A00061200A7900003020119AB10AA11A912C4 +:0A039A0012008E6449600302047033 +:1003A400E50B240FF9E4350A850913F5148915AB17 +:1003B40009AA0AA90B9000011200A7FFAB10AA1109 +:1003C400A9129000011200A76F600302047090004C +:1003D400021200A7AB09AA0AA90B90000312011983 +:1003E40090001BE4F5F01201C0AB13AA14A9157414 +:1003F40069120107AB09AA0AA90B9000011200A710 +:10040400AB13AA14A915900001120119AB09AA0A89 +:10041400A90B9000021200A7AB13AA14A91590000F +:1004240002120119AB09E50B240FF9E4350AFA7D30 +:1004340003120835AB13AA14A915900003EF120197 +:1004440019AB09E50B240FF9E4350AFAC003C0021D +:10045400C001AA0AA90B9000181201ED89828A83AF +:0C046400D001D002D0030D7C0012027AFF +:010470002269 +:06058A008B0C8A0D890EA6 +:10059000E9240FF9E43A8B0FF5108911A90E9000A8 +:1005A000021200A790000B120119AB0FAA10A9119B +:1005B0007449120107AB0CAA0DA90E900004120099 +:1005C000A7AB0FAA10A911900001120119AB0CAA38 +:1005D0000DA90E9000041200A7FF7E00E9240AF97D +:1005E000E43AFAE92FF9EE3AFA12008EAB0FAA10AC +:1005F000A911900002120119AB0CE50E240FF9E4C9 +:10060000350DFA7D03120835AB0FAA10A911900021 +:1006100003EF120119AB0CE50E240FF9E4350DFAC6 +:10062000C003C002C001AA0DA90E9000181201ED6E +:1006300089828A83D001D002D0030D7C0002027A25 +:100471008B098A0A890B12008E70030205359000E0 +:100481002112013B540F600302057A9000171200FC +:10049100A7602090001F7401120119900020120022 +:1004A100A76044AB09AA0AA90B90002074FF1200AF +:1004B100D48034AB09AA0AA90B90001DE475F001A0 +:1004C10012017390001D12013BD3940AE5F09400D0 +:1004D1004015AB09AA0AA90B900020741412011946 +:1004E10090001FE4120119AB09AA0AA90B9000019F +:1004F1001200A7D39400500302057A9000047401FE +:100501001200D49000011200A7FF9000041200A76E +:10051100D39F400EAB09AA0AA90B900004740112E3 +:100521000119AB09AA0AA90B900017E412011912CB +:10053100058A8045AB09AA0AA90B90001BE475F056 +:100541000112017390001B12013BD394C8E5F09492 +:10055100004010AB09AA0AA90B9000207464120193 +:10056100198016AB09AA0AA90B9000201200A760F6 +:100571000890002074FF1200D4AB09AA0AA90B90BD +:090581000021E475F00102017390 +:09000E008B098A0A890B8D0C2272 +:01001A0022C3 +:10064C0002074FE493A3F8E493A34003F68001F26E +:10065C0008DFF48029E493A3F85407240CC8C333AF +:10066C00C4540F4420C8834004F456800146F6DF7E +:10067C00E4800B01020408102040809008BDE47E49 +:10068C00019360BCA3FF543F30E509541FFEE49373 +:10069C00A360010ECF54C025E060A840B8E493A33A +:1006AC00FAE493A3F8E493A3C8C582C8CAC583CA65 +:1006BC00F0A3C8C582C8CAC583CADFE9DEE780BE1D +:0108CD00002A +:10008E00BB010689828A83E0225002E722BBFE0270 +:09009E00E32289828A83E49322A3 +:1000A700BB010CE58229F582E5833AF583E022500E +:1000B70006E92582F8E622BBFE06E92582F8E22258 +:0D00C700E58229F582E5833AF583E4932272 +:1000D400BB010FF8E58229F582E5833AF583E02830 +:1000E400F0225009C58229F8E58226F622BBFE09D2 +:1000F400C58229F8E22582F222F8EA2583F583E90C +:030104009328221B +:10010700BB010689828A83F0225002F722BBFE01D7 +:02011700F322D1 +:10011900F8BB010DE58229F582E5833AF583E8F01C +:10012900225006E92582C8F622BBFE05E92582C8C8 +:02013900F222B0 +:10013B00BB0110E58229F582E5833AF583E0F5F002 +:10014B00A3E0225009E92582F886F008E622BBFEDF +:10015B000AE92582F8E2F5F008E222E5832AF58325 +:08016B00E993F5F0A3E99322EA +:10017300BB010DC58229C582C5833AC58302027CB2 +:100183005011C58229F808E5F026F618F5F0E58246 +:1001930036F622BBFE11C58229F808E225F0F5F0F8 +:1001A300F218E23582F222F8E58229F582E5832A04 +:0D01B300F58374019325F0F5F0E4933822F4 +:1001C000F8BB0111E58229F582E5833AF583E8F071 +:1001D000E5F0A3F0225009E92582C8F608A6F0222E +:0D01E000BBFE09E92582C8F2E5F008F22215 +:1001ED00BB010DE58229F582E5833AF5830202A470 +:1001FD005007E92582F8020292BBFE07E92582F835 +:10020D000202B6E58229F582E5833AF5830202C83A +:10021D00BB0120E58229F582E5833AF583D0F0D044 +:10022D00E0F8D0E0F9D0E0FAD0E0FBE8C0E0C0F0B3 +:10023D000202AD5018E92582F8D083D082D0E0F9C2 +:10024D00D0E0FAD0E0FBC082C08302029BBBFE1857 +:10025D00E92582F8D083D082D0E0F9D0E0FAD0E061 +:09026D00FBC082C0830202BF2223 +:060276008A838982E47313 +:10027C00C5F0F8A3E028F0C5F0F8E582158270020D +:06028C001583E038F022AA +:09029200E6FB08E6FA08E6F92291 +:09029B00EBF608EAF608E9F62288 +:0902A400E0FBA3E0FAA3E0F9225B +:0902AD00EBF0A3EAF0A3E9F02252 +:0902B600E2FB08E2FA08E2F92279 +:0902BF00EBF208EAF208E9F22270 +:0C02C800E493FB740193FA740293F92292 +:00000001FF diff --git a/KSingleLineBus/Objects/main.obj b/KSingleLineBus/Objects/main.obj index ad95e31..cfba575 100644 --- a/KSingleLineBus/Objects/main.obj +++ b/KSingleLineBus/Objects/main.obj Binary files differ diff --git "a/MDK-ARM/KPLC_C8T6_\347\256\200\346\230\223PLC.uvprojx" "b/MDK-ARM/KPLC_C8T6_\347\256\200\346\230\223PLC.uvprojx" index c9e9d7a..2582a00 100644 --- "a/MDK-ARM/KPLC_C8T6_\347\256\200\346\230\223PLC.uvprojx" +++ "b/MDK-ARM/KPLC_C8T6_\347\256\200\346\230\223PLC.uvprojx" @@ -454,6 +454,11 @@ <FileType>5</FileType> <FilePath>..\ComLib\Inc\stm32f0xx_it.h</FilePath> </File> + <File> + <FileName>SpiFlash.h</FileName> + <FileType>5</FileType> + <FilePath>..\ComLib\Inc\SpiFlash.h</FilePath> + </File> </Files> </Group> <Group> @@ -523,6 +528,11 @@ <FileName>stm32f0xx_it.c</FileName> <FileType>1</FileType> <FilePath>..\ComLib\Src\stm32f0xx_it.c</FilePath> + </File> + <File> + <FileName>SpiFlash.c</FileName> + <FileType>1</FileType> + <FilePath>..\ComLib\Src\SpiFlash.c</FilePath> </File> </Files> </Group> @@ -694,6 +704,21 @@ <FileType>1</FileType> <FilePath>..\Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_flash.c</FilePath> </File> + <File> + <FileName>stm32f0xx_ll_i2c.c</FileName> + <FileType>1</FileType> + <FilePath>..\Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_i2c.c</FilePath> + </File> + <File> + <FileName>stm32f0xx_hal_spi.c</FileName> + <FileType>1</FileType> + <FilePath>..\Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_hal_spi.c</FilePath> + </File> + <File> + <FileName>stm32f0xx_hal_spi_ex.c</FileName> + <FileType>1</FileType> + <FilePath>..\Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_hal_spi_ex.c</FilePath> + </File> </Files> </Group> <Group> diff --git a/Radio_LLCC68/Inc/BoardType.h b/Radio_LLCC68/Inc/BoardType.h index 7285fc2..3fc96ac 100644 --- a/Radio_LLCC68/Inc/BoardType.h +++ b/Radio_LLCC68/Inc/BoardType.h @@ -76,6 +76,8 @@ #elif (BOARD_TYPE == 15) #define DINPUT 16 #define DOUTPUT 16 +#define EXDINPUT 8 +#define EXDOUPUT 8 #elif (BOARD_TYPE == 16) #define DINPUT 16 #define DOUTPUT 16 -- Gitblit v1.9.1