/*! * Check if Packet received IT flag is pending. * * @return TRUE - Packet successfully received / FALSE - No packet pending. * * @note * */ uint8 gRadio_CheckReceived_VariablePacket(void) { uint8 nirq_recv_var= SI4463_NIRQ_Bit(); if (nirq_recv_var == FALSE) { /* Read ITs, clear pending ones */ si446x_get_int_status(0u, 0u, 0u); if (Si446xCmd.GET_INT_STATUS.CHIP_PEND & SI446X_CMD_GET_CHIP_STATUS_REP_CMD_ERROR_PEND_BIT) { /* State change to */ si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_SLEEP); /* Reset FIFO */ si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT); /* State change to */ si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_RX); } /* check the reason for the IT */ if (Si446xCmd.GET_INT_STATUS.MODEM_PEND & SI446X_CMD_GET_INT_STATUS_REP_SYNC_DETECT_BIT) { /* Blink once LED2 to show Sync Word detected */ //vHmi_ChangeLedState(eHmi_Led2_c, eHmi_LedBlinkOnce_c); } if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT) { /* Blink once LED3 as CRC OK or not enabled */ // vHmi_ChangeLedState(eHmi_Led3_c, eHmi_LedBlinkOnce_c); /* Read the length of RX_FIFO */ si446x_fifo_info(0u); /* Packet RX */ si446x_read_rx_fifo(Si446xCmd.FIFO_INFO.RX_FIFO_COUNT, &fixRadioPacket[0]); /* Do not use UART in case of direct firmware load */ #ifdef UART_LOGGING_SUPPORT { /* Send it to UART */ UartSendByte(fixRadioPacket,RadioConfiguration.Radio_PacketLength); } #endif return TRUE; } if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_CRC_ERROR_BIT) { /* Reset FIFO */ si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT); } } return FALSE; }
/** * @brief send one char * @param ch char * @return the char */ int sendchar(int ch) { #ifdef BLUETOOTH_DEMO_EN vIoUartSendByte((unsigned char)ch); #else UartSendByte((unsigned char)ch); //vIoUartSendByte((unsigned char)ch); #endif return ch; }
/*! * This function is used to transmit data * * */ void SI4463_Transmit(U8 * Packet,U8 length) { static SEGMENT_VARIABLE(lPktSending, U8) = 0u; uint8 temp; // Check if the radio packet sent successfully if (TRUE == gRadio_CheckTransmitted()) { /* Clear Packet Sending flag */ temp = 2; UartSendByte(&temp,1); lPktSending = 0u; } else { temp = 3; UartSendByte(&temp,1); } //lPktSending = 0; if ((0u == lPktSending)) { uint8 flag=vSampleCode_SendFixPacket((U8 *)Packet,length); UartSendByte(&flag,1); if (TRUE == flag) { //lPer_SecCntr = 0u; /* Set Packet Sending flag */ lPktSending = 1u; } } }
int Main( void ) { U8 ch; char buf[STR_LEN]; while ( (ch = UartGetChAccept( )) != 0 ) { UartSendByte( ch ); } return 0; }
void Uart_App(void) { u8 i=0; u8 aaa[2]; aaa[0]=1; aaa[1]=2; /* Output a message on Hyperterminal using printf function */ printf("\n\Uart_App uart printf\n\r"); if(0) { while(i<10) { UartSendByte(aaa,2); i++; } /* Output a message on Hyperterminal using printf function */ printf("\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r"); /* Wait until EVAL_COM1 send the TxBuffer */ while(TxCounter < NbrOfDataToTransfer) {} /* The software must wait until TC=1. The TC flag remains cleared during all data transfers and it is set by hardware at the last frame抯 end of transmission*/ while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET) {} /* Enable the EVAL_COM1 Receive interrupt: this interrupt is generated when the EVAL_COM1 receive data register is not empty */ USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); /* Wait until EVAL_COM1 receive the RxBuffer */ while(RxCounter < NbrOfDataToRead) {} } }
/************************************************* Function: UartSwitchBuf Description: Input: Output: Return: Others: *************************************************/ static void UartSwitchBuf(void) { #if RECV_DEBUG int i; #endif mUartRecvBuf[mUartRecvIndex].State = UART_STATE_RECV; mUartRecvBuf[mUartRecvIndex].Len += 1; mUartRecvBuf[mUartRecvIndex].Buf[0] = mUartRecvBuf[mUartRecvIndex].Len; #if RECV_DEBUG for (i = 0 ; i < (mUartRecvBuf[mUartRecvIndex].Len-1); i++) { UartSendByte(mUartRecvBuf[mUartRecvIndex].Buf[1+i]); } mUartRecvBuf[mUartRecvIndex].Len = 0; mUartRecvBuf[mUartRecvIndex].State = UART_STATE_NONE; #endif mUartRecvIndex++; mUartRecvState = UART_STATE_NONE; mUartSwitchTime = 0; if(mUartRecvIndex >= UART_RECV_BUF) { mUartRecvIndex = 0; } }
void UartShowString(char str[]) { UartSendByte(str,strlen(str)); }