/*
 * Can_17_McanP.c
 *
 *  Created on: 06.10.2021
 *      Author: skv9fe
 */
#include "Can_BL.h"
#include "Can_GeneralTypes.h"
#include "CanIf.h"

CanIf_ControllerModeType Can_17_MCanP_ControllerMode[1];

void Can_17_MCanP_MainFunction_BusOff(void)
{

}
void  Can_17_MCanP_MainFunction_Read(void)
{
    fnIosPollCanRead();
}

void  Can_17_MCanP_MainFunction_Write(void)
{
    fnIosPollCanwrite();
}

Can_ReturnType Can_17_MCanP_SetControllerMode(uint8 Controller, Can_StateTransitionType Transition)

{
    switch (Transition)
    {
      case CAN_T_START :
        {
            Can_17_MCanP_ControllerMode[Controller] = CANIF_CS_STARTED;
            break;
        }


      case CAN_T_SLEEP :
        {
            Can_17_MCanP_ControllerMode[Controller] = CANIF_CS_SLEEP;

            break;
        }
      case CAN_T_STOP :
      {
          Can_17_MCanP_ControllerMode[Controller] = CANIF_CS_STOPPED;

          break;
      }

      default:    /* case CAN_T_WAKEUP */
        {

          /* Set current mode to STOPPED */
          Can_17_MCanP_ControllerMode[Controller] = CANIF_CS_STOPPED;

          break;
        }

    }
    CanIf_ControllerModeIndication(Controller, Can_17_MCanP_ControllerMode[Controller]);
    return CAN_OK;
}

Can_ReturnType Can_17_MCanP_Write (Can_HwHandleType Hth,
                                   const Can_PduType *PduInfo)
{

    fnIosCanwrite(Hth,PduInfo->length,PduInfo->sdu,PduInfo->swPduHandle);
    CanIf_TxConfirmation(PduInfo->swPduHandle);
    return CAN_OK;
}
