88 #include <stm32f4xx.h>
133 EXTI_InitStruct.
EXTI_Mode = EXTI_Mode_Interrupt;
171 memset(CARME_CAN_IRQCallbacks, 0,
sizeof(CARME_CAN_IRQCallbacks));
187 for (i = 0; i < 4; i++) {
261 CARME_CAN_IRQCallbacks[id] = pIRQCallback;
275 CARME_CAN_IRQCallbacks[id] =
NULL;
347 rxMsg->
dlc = ff & 0x0f;
372 for (i = 0; i < rxMsg->
dlc; i++) {
505 uint8_t txDataOffset;
517 unsigned char ff = 0;
527 ff |= txMsg->
dlc & 0xff;
550 for (i = 0; i <
max(txMsg->
dlc, 8); i++) {
681 for (i = 0; i < 4; i++) {
720 for (i = 0; i < 4; i++) {
728 #ifdef CARME_CAN_DEBUG
736 void CARME_CAN_PrintRegisters(
void) {
738 printf(
"PeliCAN Mode\n\r"
769 void CARME_CAN_GetRegisterString(
char* pStr) {
771 sprintf(pStr,
"PeliCAN Mode\n\r"
783 "TXERR = 0x%02x\n\r",
#define CARME_ERROR_CAN_ERROR_STATUS
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
Selects the GPIO pin used as EXTI Line.
uint8_t ERROR_CODES
Error variable.
Information about the acceptance filter.
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
uint8_t NVIC_IRQChannelPreemptionPriority
#define CARME_CAN_nCAN_IRQn_CH
void CARME_CAN_Init(uint32_t baud, uint8_t flags)
Initialize GPIOs and the CAN-Controller.
#define CARME_ERROR_CAN_INVALID_BAUDRATE
EXTIMode_TypeDef EXTI_Mode
GPIOSpeed_TypeDef GPIO_Speed
static uint8_t CARME_CAN_Read_Register(uint8_t registerAddress)
Reads a value from a SJA1000 register.
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct.
#define CARME_CAN_DF_NORMAL
#define CARME_CAN_DF_RESET
#define CARME_CAN_BAUD_250K
#define CARME_CAN_nCAN_INT_PIN
NVIC Init Structure definition.
#define SJA1000_TX_BUF(_n_)
#define NULL
SDIO Static flags, TimeOut, FIFO Address.
static void CARME_CAN_SetBusTiming(uint8_t btr0, uint8_t btr1)
Set the Bus-Timing-Registers of the SJA1000 directly.
#define max(a, b)
Get the maximum of two numbers.
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
#define CARME_ERROR_CAN_INVALID_ACCEPTANCE_MODE
#define CARME_CAN_BAUD_500K
FunctionalState NVIC_IRQChannelCmd
EXTI Init Structure definition.
enum CARME_CAN_ACCEPTANCE_FILTER_MODE afm
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
ERROR_CODES CARME_CAN_SetAcceptaceFilter(CARME_CAN_ACCEPTANCE_FILTER *af)
ACCEPTANCE FILTER With the help of the acceptance filter the CAN controller is able to allow passing ...
#define CARME_GPIO_TO_EXTIPINSOURCE(GPIO_PIN)
Get EXTI_PinSourcex from GPIO_Pin_x.
#define SJA1000_FRAMEINFO_RTR
CARME_CAN_IRQ_CALLBACKS
Interrupt sources of the CAN-Controller.
uint8_t NVIC_IRQChannelSubPriority
#define CARME_CAN_DF_LISTEN_ONLY
#define CARME_CAN_BAUD_125K
#define SJA1000_FRAMEINFO_FF
void CARME_CAN_RegisterIRQCallback(enum CARME_CAN_IRQ_CALLBACKS id, IRQ_CALLBACK pIRQCallback)
Registers a callback function. Callback functions are called in Interruptmode. Use this function afte...
#define CARME_ERROR_CAN_INVALID_MODE
SJA1000 specific declarations.
#define CARME_CAN_BAUD_1M
void CARME_CAN_InitI(uint32_t baud, uint8_t flags, uint32_t interrupts)
Initialize GPIOs and the CAN-Controller.
GPIOMode_TypeDef GPIO_Mode
static void CARME_CAN_Write_Register(uint8_t registerAddress, uint8_t val)
Write a value in a SJA1000 register.
GPIO Init structure definition.
ERROR_CODES CARME_CAN_Write(CARME_CAN_MESSAGE *txMsg)
Sends a CAN-Messsage over the CAN-Bus.
#define CARME_CAN_nCAN_INT_PORT
void CARME_CAN_UnregisterIRQCallback(enum CARME_CAN_IRQ_CALLBACKS id)
Unregisters a callback function. Callback functions are called in Interruptmode.
ERROR_CODES CARME_CAN_GetAcceptaceFilter(CARME_CAN_ACCEPTANCE_FILTER *af)
Get the Acceptance Filter settings.
EXTITrigger_TypeDef EXTI_Trigger
#define SJA1000_CDR_CANMODE
#define CARME_GPIO_TO_EXTILINE(GPIO_PIN)
Get EXTI_Linex from GPIO_Pin_x.
ERROR_CODES CARME_CAN_Read(CARME_CAN_MESSAGE *rxMsg)
Reads a CAN-Message from the Receive-Buffer. If no message is in the buffer, the function returns CAR...
#define CARME_ERROR_CAN_RXFIFO_EMPTY
ERROR_CODES CARME_CAN_SetBaudrate(uint32_t baud)
Set the baudrate for the CAN-Communication.
static void CARME_CAN_InitSTM(void)
Initialize the stm32f4xx GPIOs and the nCAN_INT. The CAN interrupt is on CARME_CAN_nCAN_IRQn_CH with...
Drivers for the CAN interface. Uses the SJA1000 CAN controller on the CARME motherboard.
#define CARME_ERROR_CAN_INVALID_OPMODE
This struct encapsulates a CAN message.
#define SJA1000_RX_BUF(_n_)
void(* IRQ_CALLBACK)()
Pointer to a function.
void CARME_CAN_Interrupt_Handler(void)
This function will be called from the Interrupt-Handler on a CAN-Interrupt. If it was not the EXTI L...
FunctionalState EXTI_LineCmd
#define CARME_GPIO_TO_EXTIPORTSOURCE(GPIO_PORT)
Get EXTI_PortSourceGPIOx from GPIOx.
ERROR_CODES CARME_CAN_SetMode(uint8_t flags)
Change operating mode from the CAN-Controller.