10#include "AustralisConfig.h"
13#include "stm32f439xx.h"
16#include "event_groups.h"
17#include "message_buffer.h"
33static TaskHandle_t vCanTransmitHandle;
34static TaskHandle_t vCanReceiveHandle;
41static CAN_t *peripheral;
42void CAN_setPeripheral(
CAN_t *peripheral_) {
43 peripheral = peripheral_;
46void __attribute__((constructor)) init() {
47 RCC_START_PERIPHERAL(APB1, CAN1);
62void vCanTransmit(
void *argument) {
63 const TickType_t blockTime = portMAX_DELAY;
66 vCanTransmitHandle = xTaskGetCurrentTaskHandle();
70 if (peripheral == NULL)
83 TickType_t xLastWakeTime = xTaskGetTickCount();
84 vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(150));
90 CAN_transmit(peripheral, &txData);
101void vCanReceive(
void *argument) {
102 const TickType_t blockTime = portMAX_DELAY;
105 vCanReceiveHandle = xTaskGetCurrentTaskHandle();
111 if (peripheral == NULL)
115 xTaskNotifyWait(0, 0, NULL, portMAX_DELAY);
117 indicator.
toggle(&indicator);
119 CAN_receive(peripheral, &rxData);
121 peripheral->interface->IER |= CAN_IER_FMPIE0;
134void pubCanInterrupt() {
135 BaseType_t xHigherPriorityTaskWoken = pdFALSE;
138 if (peripheral == NULL)
141 xTaskNotifyFromISR(vCanReceiveHandle, 0, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
142 portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
144 peripheral->interface->IER &= ~CAN_IER_FMPIE0;
#define CREATE_TOPIC(topic, commentInboxSize, messageSize)
Macro to define and initialize a topic instance.
void(* toggle)(struct GPIOpin *)
GPIOpin_t GPIOpin_init(GPIO_TypeDef *, GPIO_Pin, GPIO_Config *)
Initialiser for a GPIO peripheral pin interface.
Struct definition for a GPIO pin.
Public representation of a Topic.