| | |
| | | #include "../src/Ethernet/socket.h" |
| | | #include "../src/Ethernet/loopback.h" |
| | | #elif (BOARD_TYPE == 14) |
| | | #include "FP0.h" |
| | | #include "FPx.h" |
| | | #elif (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | #include "KWireless.h" |
| | | //#include "user.h" |
| | | //#include "../src/radio/inc/sx126x-board.h" |
| | | #endif |
| | | #include "SLP.h" |
| | | //#include "YDLidar.h" |
| | | #include "OrdLidar.h" |
| | | |
| | | /* USER CODE END Includes */ |
| | | |
| | |
| | | #define TX2BUFSIZE 64 |
| | | |
| | | |
| | | unsigned char Uart1RxBuf[128]; |
| | | unsigned char Uart1TxBuf[260]; |
| | | unsigned char Uart1RxBuf[RX1BUFSIZE]; |
| | | unsigned char Uart1TxBuf[TX1BUFSIZE]; |
| | | |
| | | unsigned char Uart2RxBuf[RX2BUFSIZE]; |
| | | unsigned char Uart2TxBuf[TX2BUFSIZE]; |
| | |
| | | unsigned char FastFlicker=0; |
| | | |
| | | unsigned int Uart1IdelTimer = 0; |
| | | #if (ENABLE_PLC) |
| | | stBinProg1 * pProgs = (stBinProg1 *)STORE_PRG_BASE; |
| | | #endif |
| | | |
| | | uint32_t us1,us2,us3,us4,us5,us6; |
| | | |
| | | stKBusDef KBus1; // |
| | | |
| | | extern stDeviceInfo MyDeviceInfo; |
| | | |
| | | unsigned char bSLPMaster =1; |
| | | unsigned char nSLPStation = 1; |
| | | |
| | | stSLPDef SLP1; |
| | | /* USER CODE END PV */ |
| | | |
| | | /* Private function prototypes -----------------------------------------------*/ |
| | |
| | | static int Count=0; |
| | | CurTickuS += 100; |
| | | nCurTick++; |
| | | nSlaveTick++; |
| | | KBus1.nSlaveTick++; |
| | | Count++; |
| | | if (Count>=10000) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | void PendSvCallBack() |
| | | { |
| | | #if (BOARD_TYPE == 14) |
| | | ///* |
| | | if (bSPI1RecvDone) |
| | | { |
| | | bSPI1RecvDone=0; |
| | | FPxParsePkt(SPI1RecvBuf,nSPI1RecvLenInBuf); |
| | | } |
| | | //*/ |
| | | #endif |
| | | if (Uart2Stat.bPacketRecved) |
| | | { |
| | | KBusParsePacket(&KBus1, (pKBPacket)Uart2RecvBuf1, Uart2RecvBuf1DataLen); |
| | | Uart2RecvBuf1DataLen=0; |
| | | Uart2Stat.bPacketRecved=0; |
| | | Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1)); |
| | | } |
| | | } |
| | | |
| | | void * KBusEvCallBackFunc(void * pParam, int nEvent, void *pBuf, int nLen1) |
| | | { |
| | | switch (nEvent){ |
| | | |
| | | case KBusEvNone: |
| | | break; |
| | | case KBusEvCreate: |
| | | break; |
| | | case KBusEvConnected: |
| | | break; |
| | | case KBusEvDisConnected: |
| | | break; |
| | | case KBusEvClosed: |
| | | break; |
| | | case KBusEvStateChange: |
| | | break; |
| | | case KBusEvTimeSync: |
| | | break; |
| | | case KBusEvDataUpdate: |
| | | KMem.WY[0]=KBusMem.WLY[0]; //KBus Slave |
| | | KBusMem.WLX[0]=KMem.WX[0]; |
| | | KBusMem.WLX[1]=KMem.WX[1]; |
| | | KBusMem.WLX[2]=KMem.WX[2]; |
| | | KBusMem.WLX[3]=KMem.WX[3]; |
| | | break; |
| | | case KBusEvCmdResponse: |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //#define RAM_START_ADDR 0x20000000 // SRAM_BASE |
| | | #define VECTOR_SIZE 46 |
| | | #define ApplicationAddress 0x08001000 //应用程序首地址定义 |
| | | /* |
| | | static void RemapIrqVector(void) |
| | | { |
| | | memcpy((void*)RAM_START_ADDR, (void *)ApplicationAddress, VECTOR_SIZE * 4); |
| | | LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SYSCFG); |
| | | LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SRAM); |
| | | } |
| | | */ |
| | | /* USER CODE END 0 */ |
| | | |
| | | /** |
| | |
| | | int main(void) |
| | | { |
| | | /* USER CODE BEGIN 1 */ |
| | | // RemapIrqVector(); |
| | | __set_PRIMASK(0); //打开全局中断 |
| | | |
| | | KMRunStat.bLEDFlick = 1; |
| | | |
| | | InitUartstat(&Uart1Stat,Uart1RxBuf,sizeof(Uart1RxBuf),Uart1TxBuf,sizeof(Uart1TxBuf)); |
| | |
| | | |
| | | /* USER CODE BEGIN Init */ |
| | | |
| | | for (int i=0;i<9;i++) |
| | | { |
| | | // memset(KBusChnStats[i],0,0); |
| | | KBusChnStats[i].SendPackets=0; |
| | | KBusChnStats[i].RecvPackets=0; |
| | | KBusChnStats[i].LostPackets=0; |
| | | KBusChnStats[i].CtnLstPkts=0; |
| | | KBusChnStats[i].MaxCtnLstPkts=0; |
| | | KBusChnStats[i].NotPkgErr=0; |
| | | KBusChnStats[i].PkgLenErr=0; |
| | | KBusChnStats[i].TimeOutErr=0; |
| | | KBusChnStats[i].BCCErr=0; |
| | | KBusChnStats[i].Delay=0; |
| | | KBusChnStats[i].MaxDelay=0; |
| | | } |
| | | |
| | | KMem.LastScanTime=0; |
| | | KMem.ScanTimeuS=0; |
| | |
| | | |
| | | /* Initialize all configured peripherals */ |
| | | MX_GPIO_Init(); |
| | | LL_GPIO_InitTypeDef GPIO_InitStruct; |
| | | 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_NO; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | MX_DMA_Init(); |
| | | |
| | | KMachineInit(); |
| | | ReadSysCfgFromFlash(&storedKMSysCfg); |
| | | |
| | | KMRunStat.bLEDFlick = 1; |
| | | |
| | | int bKBusMaster,bKBusSlave,bKBusRepeater;; |
| | | int nKBusStationId; |
| | | int nKBusChilds; |
| | | KMem.CurJumperSW=ReadJumperSW(); |
| | | KMem.EffJumperSW=KMem.CurJumperSW; |
| | | nKBusStationId=KMem.EffJumperSW&0x0f; |
| | | |
| | | nKBusChilds = nKBusStationId; |
| | | |
| | | bSLPMaster = 1; // KMem.EffJumperSW&0x20 ; //master? |
| | | nStation = 1; |
| | | |
| | | nSLPStation = 1; |
| | | SLP1.bSLPMaster = 1; |
| | | SLP1.nStation = 1; |
| | | SLPInit(&SLP1,Uart6SendPacket); |
| | | // Uart2Baud = AlterUart2Baud; |
| | | |
| | | |
| | | |
| | | #if (BOARD_TYPE == 14) |
| | | KMem.EffJumperSW|=0x10; |
| | | nStationID=KMem.EffJumperSW&0x0f; |
| | | int nKBusChilds=KMem.EffJumperSW&0x0f; |
| | | if ((KMem.EffJumperSW&0x10)!=0) {bKBusMaster=1;bKBusSlave=0;} |
| | | else{bKBusMaster=0;bKBusSlave=1;} |
| | | nChilds=nStationID; |
| | | FP0_Init(); |
| | | |
| | | FPxSetCallBackFunc(&FPxCallBackFunc); |
| | | FPx_Init(nKBusChilds); |
| | | |
| | | int IOByteCount = nKBusChilds; |
| | | FPx_SetIOCount(IOByteCount,IOByteCount); |
| | | |
| | | |
| | | #elif (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | nStationID=1 ;//KMem.EffJumperSW&0x0f; |
| | |
| | | // else |
| | | {bKBusMaster=0;bKBusSlave=1;} |
| | | #else |
| | | nStationID=KMem.EffJumperSW&0x0f; |
| | | if (KMem.EffJumperSW == 0x1f) {bKBusRepeater=1;bKBusMaster=1;bKBusSlave=0;} |
| | | else if ((KMem.EffJumperSW&0x10)!=0) {bKBusMaster=1;bKBusSlave=0;} |
| | | nKBusStationId=KMem.EffJumperSW&0x0f; |
| | | if (KMem.EffJumperSW == 0x3f) {bKBusRepeater=1;bKBusMaster=1;bKBusSlave=0;} |
| | | else if ((KMem.EffJumperSW&0x20)!=0) {bKBusMaster=1;bKBusSlave=0;} |
| | | else{bKBusMaster=0;bKBusSlave=1;} |
| | | #endif |
| | | nChilds=nStationID; |
| | | nCurPollId=1; |
| | | |
| | | if (bKBusMaster) { |
| | | KBusInitMaster(&KBus1, (KBusSendPktFuncDef)PutStr2, nKBusChilds); |
| | | |
| | | } else if (bKBusSlave) { |
| | | KBusInitSlave(&KBus1, (KBusSendPktFuncDef)PutStr2, nKBusStationId,&MyDeviceInfo); |
| | | } |
| | | |
| | | KBusSetEvCallBackFunc(&KBus1, &KBusEvCallBackFunc); |
| | | |
| | | //if (KMem.EffJumperSW == 0x00) |
| | | Uart1Baud = DefaultUart1Baud; |
| | | MX_USART1_UART_Init(); |
| | | MX_USART2_UART_Init(); |
| | | // MX_USART5_UART_Init(); |
| | | // LL_USART_EnableIT_RXNE(USART5); |
| | | // LL_USART_EnableIT_IDLE(USART5); |
| | | |
| | | MX_USART3_UART_Init(); |
| | | |
| | | LL_USART_EnableIT_RXNE(USART3); |
| | | LL_USART_EnableIT_IDLE(USART3); |
| | | |
| | | MX_USART5_UART_Init(); |
| | | LL_USART_EnableIT_RXNE(USART5); |
| | | LL_USART_EnableIT_IDLE(USART5); |
| | | |
| | | MX_USART6_UART_Init(); |
| | | LL_USART_EnableIT_RXNE(USART6); |
| | |
| | | KMRunStat.WorkMode2=0; |
| | | |
| | | KMRunStat.WorkMode = storedKMSysCfg.theKMSysCfg.workmode; |
| | | |
| | | #if (ENABLE_PLC) |
| | | if (KMRunStat.WorkMode == 1){ |
| | | InitPLC(); |
| | | KMRunStat.WorkMode2 = KMem.CurJumperSW&0x20 ; |
| | | if (KMRunStat.WorkMode2) { |
| | | StartPLC(); } |
| | | } |
| | | KMem.WX[7]=0x5a; |
| | | #endif |
| | | |
| | | #if (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | KWireLessInit(KMem.EffJumperSW&0x20,KMem.EffJumperSW&0x0f); |
| | | KWireLessStart(); |
| | | #endif |
| | | |
| | | OrdLidarStart(-1); |
| | | |
| | | while (1) |
| | | { |
| | |
| | | int haltick=HAL_GetTick(); |
| | | |
| | | int thisJumperSW=ReadJumperSW(); |
| | | |
| | | #if (ENABLE_PLC) |
| | | if (KMRunStat.WorkMode&1){ |
| | | if (thisJumperSW&0x20 && !(KMem.CurJumperSW&0x20)) // Run 开关 正 跳变。 |
| | | {StartPLC();} |
| | | if (!(thisJumperSW&0x20) && (KMem.CurJumperSW&0x20)) // Run 开关 负 跳变。 |
| | | {StopPLC();} |
| | | } |
| | | |
| | | #endif |
| | | KMem.CurJumperSW=thisJumperSW; |
| | | KMem.haltick=haltick; |
| | | // KMem.TotalRunTime=TotalRunTime; |
| | |
| | | a = LL_GPIO_ReadInputPort(GPIOD); |
| | | KMem.WDT[123]=a; |
| | | |
| | | #if (BOARD_TYPE == 14) |
| | | // KMem.WX[0]= GetInput(); |
| | | FP0_Proc(); |
| | | #else |
| | | KMem.WXB[0]= GetInput(); |
| | | #endif |
| | | |
| | | if (GetBoardType() == 7 || GetBoardType() ==8 |
| | | || GetBoardType() == 9 || GetBoardType() ==10 || GetBoardType() ==15 || GetBoardType() ==16) |
| | | { |
| | | displayInput(KMem.WX[0]); |
| | | } |
| | | KMem.WXB[0]= GetInput(); |
| | | |
| | | us2=GetuS(); |
| | | if (PowerDownEvent) { KMem.WX[0]=0;} |
| | | ///* |
| | |
| | | } |
| | | //*/ |
| | | |
| | | #if (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | Radio.IrqProcess( ); // Process Radio IRQ |
| | | KWL_Process(1); |
| | | |
| | | #endif |
| | | |
| | | // pProgs = (stBinProg1 *) STORE_PRG_BASE; |
| | | |
| | | #if (ENABLE_PLC) |
| | | if ( KMRunStat.WorkMode==1 ) //&& bKBusMaster) |
| | | { |
| | | if (KMRunStat.nBinProgBank == 0){ |
| | |
| | | |
| | | ProcessPLCBinProg(pProgs, nSizeProg1); |
| | | } |
| | | #endif |
| | | |
| | | KMem.ScanTimeuS=us2-KMem.LastScanTime; |
| | | KMem.LastScanTime = us2; |
| | |
| | | |
| | | if (bKBusMaster) |
| | | { |
| | | #if (BOARD_TYPE == 14) |
| | | for (int i=0;i<nOutputBytes;i++) |
| | | {BufferOut[i+1]=KMem.WYB[i];} |
| | | #else |
| | | // BufferOut[1]=KMem.WX[0]&0xff; |
| | | // BufferOut[2]=(KMem.WX[0]>>8)&0xff; |
| | | #endif |
| | | if (nChilds>0) { KBusMasterFunc(2); } |
| | | |
| | | #if (BOARD_TYPE == 14) |
| | | // KMem.WX[0]=BufferIn[1]+(BufferIn[2]<<8); |
| | | #else |
| | | // KMem.WY[0]=BufferIn[1]+(BufferIn[2]<<8); |
| | | #endif |
| | | |
| | | KBusLoopProcess(&KBus1); |
| | | } |
| | | if (haltick&0x00002000) SlowFlicker=1; |
| | | else SlowFlicker=0; |
| | |
| | | |
| | | if (bKBusSlave) |
| | | { |
| | | // BufferOut[0]=KMem.WX[0]; |
| | | #if (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | // KBusSlaveFunc(2); |
| | | // if (! KMem.RunStat) {BufferIn[0]=0;} |
| | | // KMem.WY[0]=BufferIn[0]; |
| | | #else |
| | | KBusSlaveFunc(2); |
| | | if (! KMem.RunStat) {BufferIn[0]=0;} |
| | | KMem.WLY[0]=BufferIn[0]; |
| | | #endif |
| | | if (nSlaveTick&0x00002000) SlowFlicker=1; |
| | | |
| | | KBusLoopProcess(&KBus1); |
| | | // if (! KBus1.RunStat) {KBusMem.WLY[0]=0;} |
| | | KMem.WLY[0]=KBusMem.WLY[0]; |
| | | |
| | | if (KBus1.nSlaveTick&0x00002000) SlowFlicker=1; |
| | | else SlowFlicker=0; |
| | | if (nSlaveTick&0x00000800) FastFlicker=1; |
| | | if (KBus1.nSlaveTick&0x00000800) FastFlicker=1; |
| | | else FastFlicker=0; |
| | | |
| | | } |
| | | KBusMem.WLX[0]=KMem.WX[0]; |
| | | KMem.WY[0]=KBusMem.WLY[0]; |
| | | KBusMem.WLX[1]=KMem.WX[1]; |
| | | KBusMem.WLX[2]=KMem.WX[2]; |
| | | KBusMem.WLX[3]=KMem.WX[3]; |
| | | |
| | | // KMem.WY[0]=nCount2>>5; |
| | | if (KMem.RunStat) {KMem.RunStat--;} |
| | | if (KMem.ErrStat) {KMem.ErrStat--;} |
| | | |
| | | if (KMRunStat.bLEDFlick) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | #if (ENABLE_PLC) |
| | | if (KMRunStat.WorkMode==1 ) { |
| | | if (PLCMem.bPLCRunning){SetRunLed(SlowFlicker);} |
| | | else {SetRunLed(0);} |
| | | } |
| | | else { |
| | | else |
| | | #endif |
| | | { |
| | | if (!KMem.RunStat) SetRunLed(SlowFlicker); |
| | | else SetRunLed(FastFlicker); |
| | | } |
| | | KMem.ErrStat = KBus1.ErrStat + SLP1.SLPErrSign; |
| | | if (!KMem.ErrStat) |
| | | { |
| | | SetErrLed(0); |
| | |
| | | us4=GetuS(); |
| | | // EffJumperSW = GetInput(20)&0xff; |
| | | |
| | | #if (BOARD_TYPE == 15 || BOARD_TYPE == 16) |
| | | |
| | | if ((KMem.EffJumperSW&0x10)==0x10) { |
| | | KMem.WFY[1]=KMem.WLY[0]; |
| | | KMem.WLX[0]=KMem.WFX[1]; |
| | | }else |
| | | { |
| | | KMem.WFY[1]=KMem.WX[0]; |
| | | KMem.WY[0]=KMem.WFX[1]; |
| | | } |
| | | // KMem.WY[0]=KMem.WLY[0]; |
| | | #else |
| | | KMem.WLX[0]=KMem.WX[0]; |
| | | KMem.WY[0]=KMem.WLY[0]; |
| | | #endif |
| | | |
| | | us5=GetuS(); |
| | | |
| | |
| | | // 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 (Uart1Stat.bPacketRecved && Uart1RecvBuf1DataLen >0) |
| | | { |
| | | int res1 = -1; |
| | | if (Uart1RecvBuf1[0] == KLSignStart) { |
| | | res1 = KLParsePacket(1, Uart1RecvBuf1, Uart1RecvBuf1DataLen); |
| | | }else { |
| | | res1 = ModBusSlaveParsePkg(1, Uart1RecvBuf1, Uart1RecvBuf1DataLen); |
| | | if (res1 !=0) |
| | | { |
| | | KLParsePacket(1, Uart1RecvBuf1, Uart1RecvBuf1DataLen); |
| | | } |
| | | Uart1RecvBuf1DataLen=0; |
| | | Uart1Stat.bPacketRecved=0; |
| | | Uart1RecvBuf1DataLen=0; |
| | | Uart1IdelTimer = 0; |
| | | }else { |
| | | if (Uart1IdelTimer>600000) { // 超过60秒没有数据传输,重新进入自适应波特率状态 |
| | |
| | | if (bKBusSlave) HAL_Delay(0); |
| | | |
| | | if (Uart6Stat.bPacketRecved){ |
| | | SLPparsePacket(Uart6RxBuf,Uart6RecvBuf1DataLen); |
| | | SLPparsePacket(&SLP1,Uart6RxBuf,Uart6RecvBuf1DataLen); |
| | | Uart6RecvBuf1DataLen =0; |
| | | Uart6Stat.bPacketRecved = 0; |
| | | } |
| | | SLP1.SLPinputB = KMem.WYB[1]; |
| | | SLPProcess(&SLP1); |
| | | KMem.WXB[1] = SLP1.SLPoutputB; |
| | | |
| | | SLPinputB = KMem.WYB[1]; |
| | | SLPProcess(); |
| | | KMem.WXB[1] = SLPoutputB; |
| | | // YDLiDar process; |
| | | |
| | | /* |
| | | if ((KMem.nRunCount&0x7f)==1) { |
| | | |
| | | SLPSendPacket("ABCDEF",6); |
| | | |
| | | }; |
| | | */ |
| | | |
| | | /* |
| | | if (!IsEmpty(&Uart1Stat.QRx)) |
| | | { |
| | | unsigned char k=PopOne(&Uart1Stat.QRx); |
| | | if (k=='L') |
| | | { |
| | | clearscreen(); |
| | | if (Uart3Stat.bPacketRecved){ |
| | | KMem.WDT[8]++; |
| | | OrdLidarParsePkt(0,(OradarLidarFrame *)Uart3RxBuf,Uart3RecvBuf1DataLen); |
| | | Uart3RecvBuf1DataLen =0; |
| | | Uart3Stat.bPacketRecved = 0; |
| | | } |
| | | KMem.WDT[9]=pCount1; |
| | | KMem.WDT[10]=dCount1; |
| | | KMem.WDT[11]=vCount1; |
| | | |
| | | KMem.WDT[12] = eCount1; |
| | | KMem.WDT[13] = eCount2; |
| | | |
| | | if (Uart5Stat.bPacketRecved){ |
| | | KMem.WDT[16]++; |
| | | OrdLidarParsePkt(1,(OradarLidarFrame *)Uart5RxBuf,Uart5RecvBuf1DataLen); |
| | | Uart5RecvBuf1DataLen =0; |
| | | Uart5Stat.bPacketRecved = 0; |
| | | } |
| | | */ |
| | | #if (BOARD_TYPE == 14) |
| | | // PutOutput (KMem.WY[0]); |
| | | #else |
| | | |
| | | // nPosX,nPosY,nPosZ,nPosZ1,nPosZ2; |
| | | |
| | | KMem.WDT[17]=pCount2; |
| | | KMem.WDT[18]=dCount2; |
| | | KMem.WDT[19]=vCount2; |
| | | |
| | | KMem.WDT[24]=nPosX; |
| | | KMem.WDT[25]=nPosY; |
| | | KMem.WDT[26]=nPosZ; |
| | | KMem.WDT[27]=nPosZ1; |
| | | KMem.WDT[28]=nPosZ2; |
| | | |
| | | KMem.WDT[32]=results[0]; |
| | | KMem.WDT[33]=results[1]; |
| | | KMem.WDT[34]=results[2]; |
| | | KMem.WDT[35]=results[3]; |
| | | KMem.WDT[36]=results[4]; |
| | | KMem.WDT[37]=results[5]; |
| | | KMem.WDT[38]=results[6]; |
| | | KMem.WDT[39]=results[7]; |
| | | |
| | | |
| | | KMem.WX[1] = nPosX ; |
| | | KMem.WX[2] = nPosY ; |
| | | KMem.WX[3] = nPosZ; |
| | | |
| | | // KMem.WX[1]++ ; |
| | | // KMem.WX[2]++; |
| | | |
| | | // KMem.WYB[0]=1; |
| | | PutOutput (KMem.WY[0]); |
| | | |
| | | #endif |
| | | |
| | | #if (BOARD_TYPE == 14) |
| | | const unsigned int pins[6]= { LL_GPIO_PIN_10,LL_GPIO_PIN_11,LL_GPIO_PIN_12,LL_GPIO_PIN_13,LL_GPIO_PIN_14,LL_GPIO_PIN_15}; |
| | | //process 6 output |
| | | { |
| | | // mapping bits. |
| | | for (int i=0;i<6;i++) |
| | | { |
| | | USHORT bitaddr = storedKMSysCfg.theKMSysCfg.OutMappings[i]; |
| | | UCHAR type = (bitaddr&0xf000) >>12; |
| | | USHORT byteaddr = (bitaddr&0x0ff0) >>4; |
| | | UCHAR bitpos = bitaddr &0x0f; |
| | | UCHAR bitvalue = 0 ; |
| | | if (byteaddr>0) { |
| | | if (type == 0) bitvalue = KMem.WXB[byteaddr-1] & ( 1 << bitpos ); |
| | | else if (type == 1 ) bitvalue = KMem.WYB[byteaddr-1] & ( 1 << bitpos ); |
| | | } |
| | | if (bitvalue){ LL_GPIO_SetOutputPin(GPIOB,pins[i]);} |
| | | else {LL_GPIO_ResetOutputPin(GPIOB,pins[i]);} |
| | | } |
| | | } |
| | | #endif |
| | | |
| | | /* |
| | | { |
| | | unsigned char pos,seg; |
| | | unsigned short val; |
| | | pos=((KMem.nRunCount)&0x3); |
| | | //val=(KMem.nRunCount)&0xfff; |
| | | val=KMem.ErrStat; |
| | | char buf5[20]; |
| | | sprintf(buf5,"%4d",val); |
| | | val=buf5[3-pos]; |
| | | if (val <'0' || val >'9') {seg=0;} |
| | | else {seg=LEDSEGTAB[val-'0'];} |
| | | |
| | | pos=1<<pos; |
| | | //pos=1; |
| | | //seg=2; |
| | | seg=~seg; |
| | | // PutOutputSPI1(pos|(seg<<8)); |
| | | } |
| | | */ |
| | | |
| | | #if (BOARD_TYPE == 13) |
| | | w5500_network_info_show(); |
| | | // loopback_tcps(0,str1,5000); |
| | | #endif |
| | | |
| | | LL_IWDG_ReloadCounter(IWDG); |
| | | |