| | |
| | | return nCurTick;
|
| | | }
|
| | |
|
| | | void logData(unsigned char d)
|
| | | {
|
| | | KMem.WDB[128+KMem.WDT[123]] = d;
|
| | | KMem.WDT[123]++; if (KMem.WDT[123]>=100) {KMem.WDT[123]=81;} |
| | | }
|
| | |
|
| | | const unsigned short crc16_table[256] = {
|
| | | 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
| | | 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
| | |
| | | LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_2,nSize);
|
| | | LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_2);
|
| | | Uart1Stat.DMASendLen=nSize;
|
| | | Uart1Stat.Sending=1; |
| | | Uart1Stat.bSending=1; |
| | | LL_DMA_EnableIT_TC(DMA1,LL_DMA_CHANNEL_2);
|
| | | LL_USART_EnableDMAReq_TX(USART1);
|
| | | return nSize;
|
| | |
| | |
|
| | | int Uart1TriggerSendDMA()
|
| | | {
|
| | | if (!Uart1Stat.Sending&&!IsEmpty(&Uart1Stat.QTx))
|
| | | if (!Uart1Stat.bSending&&!IsEmpty(&Uart1Stat.QTx))
|
| | | {
|
| | | int len1=GetContinueData(&Uart1Stat.QTx);
|
| | | Uart1SendDMA(GetReadBuffer(&Uart1Stat.QTx),len1);
|
| | |
| | | LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_5,nSize);
|
| | | LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_5);
|
| | | Uart2Stat.DMARecvLen=nSize;
|
| | | Uart2Stat.Recving=1; |
| | | Uart2Stat.bRecving=1; |
| | | LL_DMA_EnableIT_TC(DMA1,LL_DMA_CHANNEL_5);
|
| | | LL_USART_EnableDMAReq_RX(USART2);
|
| | | return 0;
|
| | |
| | | LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_4,nSize);
|
| | | LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_4);
|
| | | Uart2Stat.DMASendLen=nSize;
|
| | | Uart2Stat.Sending=1; |
| | | Uart2Stat.bSending=1; |
| | | LL_DMA_EnableIT_TC(DMA1,LL_DMA_CHANNEL_4);
|
| | | LL_USART_EnableDMAReq_TX(USART2);
|
| | | return nSize;
|
| | | }
|
| | | int Uart2TriggerSendDMA()
|
| | | {
|
| | | if (!Uart2Stat.Sending&&!IsEmpty(&Uart2Stat.QTx))
|
| | | if (!Uart2Stat.bSending&&!IsEmpty(&Uart2Stat.QTx))
|
| | | {
|
| | | int len1=GetContinueData(&Uart2Stat.QTx);
|
| | | Uart2SendDMA(GetReadBuffer(&Uart2Stat.QTx),len1);
|
| | |
| | | #endif
|
| | | if (Uart2Stat.bPacketRecved)
|
| | | {
|
| | | KBusParsePacket(2, (pPacket)Uart2RecvBuf1, Uart2RecvBuf1DataLen); |
| | | KBusParsePacket(2, (pKBPacket)Uart2RecvBuf1, Uart2RecvBuf1DataLen); |
| | | Uart2RecvBuf1DataLen=0;
|
| | | Uart2Stat.bPacketRecved=0;
|
| | | Uart2RecvDMA(Uart2RecvBuf1,sizeof(Uart2RecvBuf1));
|
| | |
| | | {
|
| | | value = LL_SPI_ReceiveData8( SPI1);
|
| | | #if (BOARD_TYPE == 14)
|
| | | KMem.SDD[62]++;
|
| | | KMem.SDT[122]++;
|
| | | KMem.WDD[62]++;
|
| | | KMem.WDT[122]++;
|
| | | if (!bSPI1Sending)
|
| | | {
|
| | | KMem.SDB[128+KMem.SDT[123]] = value;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;}
|
| | | logData(value);
|
| | | }
|
| | | if (!bSPI1Sending && (1 || bSPI1Recving))
|
| | | {
|
| | |
| | |
|
| | | if (value==0x0d)
|
| | | {
|
| | | KMem.SDB[128+KMem.SDT[123]] = nSPI1RecvPos;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;}
|
| | | logData(nSPI1RecvPos);
|
| | |
|
| | | nSPI1RecvLenInBuf=nSPI1RecvPos;
|
| | | bSPI1RecvDone=1;
|
| | |
| | | else {
|
| | | value = SPI1SendBuf[nSPI1SentLen];
|
| | | LL_SPI_TransmitData8(SPI1,value);
|
| | | KMem.SDB[128+KMem.SDT[123]] = value;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;} |
| | | logData(value);
|
| | | }
|
| | | }
|
| | | #endif
|
| | |
| | | Uart2Stat.IdelCount++;
|
| | | if (Uart2RecvBuf1DataLen>0)
|
| | | TriggerPendSV();
|
| | | // ParsePacket((pPacket)Uart2RecvBuf1,Uart2RecvBuf1DataLen);
|
| | | // ParsePacket((pKBPacket)Uart2RecvBuf1,Uart2RecvBuf1DataLen);
|
| | | }
|
| | |
|
| | | int PutStr(char * str1, int len1)
|
| | |
| | | Uart1Stat.SentPacket++;
|
| | | return len1;
|
| | | }
|
| | | int SendPacket2(pPacket p1,int len1)
|
| | | int SendPacket2(pKBPacket p1,int len1)
|
| | | {
|
| | | PutStr2((char *)p1,len1);
|
| | | // PushIn(&Uart2Stat.QTx,p1,len1);
|
| | |
| | | */
|
| | | void ToggleRunLed() { LL_GPIO_TogglePin(GPIOC,LL_GPIO_PIN_13);}
|
| | | void ToggleErrLed() { LL_GPIO_TogglePin(GPIOC,LL_GPIO_PIN_14);}
|
| | | void ToggleErr2Led() { LL_GPIO_TogglePin(GPIOC,LL_GPIO_PIN_15);}
|
| | |
|
| | | #if (BOARD_TYPE == 14)
|
| | | void ToggleOutStat() { LL_GPIO_TogglePin(GPIOC,LL_GPIO_PIN_15);}
|
| | |
|
| | |
| | | if (bOn) {LL_GPIO_ResetOutputPin(GPIOC,LL_GPIO_PIN_14);}
|
| | | else {LL_GPIO_SetOutputPin(GPIOC,LL_GPIO_PIN_14);}
|
| | | }
|
| | | void SetErr2Led(uchar bOn)
|
| | | {
|
| | | if (bOn) {LL_GPIO_ResetOutputPin(GPIOC,LL_GPIO_PIN_15);}
|
| | | else {LL_GPIO_SetOutputPin(GPIOC,LL_GPIO_PIN_15);} |
| | | }
|
| | | /*
|
| | | void SetLeds(uchar bRun, uchar bErr)
|
| | | {
|
| | | SetRunLed(bRun); SetErrLed (bErr);
|
| | | }
|
| | |
|
| | | */
|
| | | #define set165SL_0() LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_4)
|
| | | #define set165SL_1() LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_4)
|
| | | #define set165CLK_0() LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_5)
|
| | |
| | | return 0; //FP0
|
| | | case 15:
|
| | | return Input165_R(16);
|
| | | case 16:
|
| | | return Input165_R(8);
|
| | | |
| | | default:
|
| | | break;
|
| | | }
|
| | |
| | | case 14:
|
| | | return (~(LL_GPIO_ReadInputPort(GPIOA)>>4))&0x0f; //FP0
|
| | | case 15:
|
| | | case 16:
|
| | | return ReadConfig_5(); //Wireless Master Slave 8 in 8 o
|
| | | default:
|
| | |
|
| | |
| | | {
|
| | | #if (BOARD_TYPE == 14)
|
| | | return ;
|
| | | #endif
|
| | | #else
|
| | | PutOutputSPI2(Y);
|
| | | //Output595_16(Y);
|
| | | #endif
|
| | | }
|
| | |
|
| | | #if (BOARD_TYPE == 9 || BOARD_TYPE == 10 || BOARD_TYPE == 15 )
|
| | | #if (BOARD_TYPE == 9 || BOARD_TYPE == 10 || BOARD_TYPE == 15 || BOARD_TYPE == 16)
|
| | | //#pragma message("9,10")
|
| | | // V4.2 管脚排列向右移动了一位。
|
| | | #define SRCLK1_0() LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_1)
|