Index: source/sci.c =================================================================== diff -u -r3323966fe741edbb36dffc78317ccf06ed93a68e -rcb47c5f896477ceae7597cb1a4191b3972e93f0d --- source/sci.c (.../sci.c) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ source/sci.c (.../sci.c) (revision cb47c5f896477ceae7597cb1a4191b3972e93f0d) @@ -96,7 +96,7 @@ | (uint32)((uint32)1U << 1U); /* asynchronous timing mode */ /** - set baudrate */ - sciREG->BRS = 55U; /* baudrate */ + sciREG->BRS = 6U; /* baudrate */ /** - transmission length */ sciREG->FORMAT = 8U - 1U; /* length */ @@ -138,12 +138,12 @@ sciREG->SETINT = (uint32)((uint32)1U << 26U) /* Framing error */ | (uint32)((uint32)1U << 25U) /* Overrun error */ | (uint32)((uint32)0U << 24U) /* Parity error */ - | (uint32)((uint32)1U << 9U) /* Receive */ + | (uint32)((uint32)0U << 9U) /* Receive */ | (uint32)((uint32)0U << 1U) /* Wakeup */ | (uint32)((uint32)0U << 0U); /* Break detect */ /** - initialize global transfer variables */ - g_sciTransfer_t[0U].mode = (uint32)1U << 8U; + g_sciTransfer_t[0U].mode = (uint32)0U << 8U; g_sciTransfer_t[0U].tx_length = 0U; g_sciTransfer_t[0U].rx_length = 0U; @@ -793,7 +793,165 @@ } } +/* USER CODE BEGIN (27) */ +/* USER CODE END */ +/** @fn void sciHighLevelInterrupt(void) +* @brief Level 0 Interrupt for SCI +*/ +#pragma CODE_STATE(sciHighLevelInterrupt, 32) +#pragma INTERRUPT(sciHighLevelInterrupt, FIQ) + +/* SourceId : SCI_SourceId_018 */ +/* DesignId : SCI_DesignId_017 */ +/* Requirements : HL_SR245, HL_SR246 */ +void sciHighLevelInterrupt(void) +{ + uint32 vec = sciREG->INTVECT0; + uint8 byte; +/* USER CODE BEGIN (28) */ +/* USER CODE END */ + + switch (vec) + { + case 1U: + sciNotification(sciREG, (uint32)SCI_WAKE_INT); + break; + case 3U: + sciNotification(sciREG, (uint32)SCI_PE_INT); + break; + case 6U: + sciNotification(sciREG, (uint32)SCI_FE_INT); + break; + case 7U: + sciNotification(sciREG, (uint32)SCI_BREAK_INT); + break; + case 9U: + sciNotification(sciREG, (uint32)SCI_OE_INT); + break; + + case 11U: + /* receive */ + byte = (uint8)(sciREG->RD & 0x000000FFU); + + if (g_sciTransfer_t[0U].rx_length > 0U) + { + *g_sciTransfer_t[0U].rx_data = byte; + /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */ + g_sciTransfer_t[0U].rx_data++; + g_sciTransfer_t[0U].rx_length--; + if (g_sciTransfer_t[0U].rx_length == 0U) + { + sciNotification(sciREG, (uint32)SCI_RX_INT); + } + } + break; + + case 12U: + /* transmit */ + /*SAFETYMCUSW 30 S MR:12.2,12.3 "Used for data count in Transmit/Receive polling and Interrupt mode" */ + --g_sciTransfer_t[0U].tx_length; + if (g_sciTransfer_t[0U].tx_length > 0U) + { + uint8 txdata = *g_sciTransfer_t[0U].tx_data; + sciREG->TD = (uint32)(txdata); + /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */ + g_sciTransfer_t[0U].tx_data++; + } + else + { + sciREG->CLEARINT = (uint32)SCI_TX_INT; + sciNotification(sciREG, (uint32)SCI_TX_INT); + } + break; + + default: + /* phantom interrupt, clear flags and return */ + sciREG->FLR = ~sciREG->SETINTLVL & 0x07000303U; + break; + } +/* USER CODE BEGIN (29) */ +/* USER CODE END */ +} + + +/** @fn void linHighLevelInterrupt(void) +* @brief Level 0 Interrupt for SCILIN +*/ +#pragma CODE_STATE(linHighLevelInterrupt, 32) +#pragma INTERRUPT(linHighLevelInterrupt, FIQ) + +/* SourceId : SCI_SourceId_021 */ +/* DesignId : SCI_DesignId_017 */ +/* Requirements : HL_SR245, HL_SR246 */ +void linHighLevelInterrupt(void) +{ + uint32 vec = scilinREG->INTVECT0; + uint8 byte; +/* USER CODE BEGIN (35) */ +/* USER CODE END */ + + switch (vec) + { + case 1U: + sciNotification(scilinREG, (uint32)SCI_WAKE_INT); + break; + case 3U: + sciNotification(scilinREG, (uint32)SCI_PE_INT); + break; + case 6U: + sciNotification(scilinREG, (uint32)SCI_FE_INT); + break; + case 7U: + sciNotification(scilinREG, (uint32)SCI_BREAK_INT); + break; + case 9U: + sciNotification(scilinREG, (uint32)SCI_OE_INT); + break; + + case 11U: + /* receive */ + byte = (uint8)(scilinREG->RD & 0x000000FFU); + + if (g_sciTransfer_t[1U].rx_length > 0U) + { + *g_sciTransfer_t[1U].rx_data = byte; + /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */ + g_sciTransfer_t[1U].rx_data++; + g_sciTransfer_t[1U].rx_length--; + if (g_sciTransfer_t[1U].rx_length == 0U) + { + sciNotification(scilinREG, (uint32)SCI_RX_INT); + } + } + break; + + case 12U: + /* transmit */ + /*SAFETYMCUSW 30 S MR:12.2,12.3 "Used for data count in Transmit/Receive polling and Interrupt mode" */ + --g_sciTransfer_t[1U].tx_length; + if (g_sciTransfer_t[1U].tx_length > 0U) + { + uint8 txdata = *g_sciTransfer_t[1U].tx_data; + scilinREG->TD = (uint32)(txdata); + /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */ + g_sciTransfer_t[1U].tx_data++; + } + else + { + scilinREG->CLEARINT = (uint32)SCI_TX_INT; + sciNotification(scilinREG, (uint32)SCI_TX_INT); + } + break; + + default: + /* phantom interrupt, clear flags and return */ + scilinREG->FLR = ~scilinREG->SETINTLVL & 0x07000303U; + break; + } +/* USER CODE BEGIN (36) */ +/* USER CODE END */ +} /* USER CODE BEGIN (37) */ /* USER CODE END */