Autosar specification restricts the Fr_StartCommunication to be use only for starting the communication and no other logic should be there.
The specification orders the Fr_ControllerInit function to be able to switch POC state to Config from any other states. So all the restart logic was moved here.
Commands descriptions and rpp function documentation was modified.
/**
* FlexRay controller initialization.
*
- * This method should be called after rpp_fr_init_driver() and before any
- * other function from this module.
+ * This method should be called after rpp_fr_init_driver() or rpp_fr_halt_communication() and
+ * rpp_fr_abort_communication() and before any other function from this module.
+ *
+ * To restart communication after halt or abort functions were called, this sequence should be used:
+ * - rpp_fr_init_controller
+ * - rpp_fr_start_communication
+ * -rpp_fr_all_slots (optionally)
*
* The functions checks configuration parameters and configures FlexRay
* controller registers.
* FlexRay start communication
*
* This method should be called after rpp_fr_init_controller() and
- * before any attempt to send or receive messages. If the communication
- * has been halted by rpp_fr_halt_communication() or rpp_fr_abort_communication(),
- * this function has to be called to restart the communication.
+ * before any attempt to send or receive messages.
*
* For coldstarter node the function tries to listen and join an
* existing network. If it fails, it tries to initiate the new one.
uint8_t totalBufferCount;
#ifdef DET_ACTIVATED
- if (Fr_DrvState != FR_ST_DRV_INITIALIZED) {
+ if (Fr_DrvState < FR_ST_DRV_INITIALIZED) {
return E_NOT_OK;
}
#endif
/* Switch CC into ‘POC:config’ (from any other POCState) */
- if (Fr_POC_go_to_config() == E_NOT_OK) {
- return E_NOT_OK;
+ while (frayREG->CCSV_UN.CCSV_ST.pocs_B6 != FR_POCS_CONFIG) {
+ if (Fr_POC_go_to_config() == E_NOT_OK) {
+ return E_NOT_OK;
+ }
}
+
/* Check Cluster config parameters */
if (Fr_check_cluster_parameters(Fr_Config->clusterConfiguration, &errCode) == E_NOT_OK) {
return E_NOT_OK | errCode | FR_INIT_ERR_CLUSTER_CONFIG;
totalBufferCount = Fr_config_msgRAM_parameters(Fr_Config->msgRAMConfig);
Fr_MsgRAMDataStartAddress = totalBufferCount*4U; // First data section after headers sections in message RAM.
Fr_MsgRAMDataOffset = Fr_MsgRAMDataStartAddress;
+
+ /* Reset configured flags */
+ for (i = 0; i < totalBufferCount; i++) {
+ Fr_BuffersConfigured[i] = FALSE;
+ }
+
/* Configure all transmit/receive resources */
for (i = 0; i < totalBufferCount; i++) {
if (Fr_PrepareLPdu(Fr_CtrlIdx, Fr_buffer_slot_map[i].buffer_ptr->slotId) == E_NOT_OK) {
if (Fr_CtrlIdx != 0) {
return E_NOT_OK;
}
- if (Fr_DrvState != FR_ST_DRV_INITIALIZED) {
+ if (Fr_DrvState < FR_ST_DRV_INITIALIZED) {
return E_NOT_OK;
}
if (Fr_LPduIdx > cSlotIDMax) {
int8_t rpp_fr_init_controller(uint8_t ctrl, uint32_t* error) {
Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
- if (rpp_fr_state == RPP_FR_DRV_INITIALIZED) {
+ if (rpp_fr_state == RPP_FR_DRV_INITIALIZED ||
+ rpp_fr_state == RPP_FR_HALTED ||
+ rpp_fr_state == RPP_FR_ABORTED) {
retVal = Fr_ControllerInit(ctrl);
if (retVal & E_OK) {
rpp_fr_state = RPP_FR_CTR_INITIALIZED;
int8_t rpp_fr_start_communication(uint8_t ctrl, uint32_t* error) {
Std_ReturnType retVal = ERR_PARAM_NO_ERROR;
- if (rpp_fr_state >= RPP_FR_CTR_INITIALIZED) {
+ if (rpp_fr_state == RPP_FR_CTR_INITIALIZED) {
retVal = Fr_StartCommunication(ctrl);
if (retVal & E_OK) {
rpp_fr_state = RPP_FR_RUNNING;