Midnight Sun Firmware
Loading...
Searching...
No Matches
bootloader_can_datagram.h
1#pragma once
2
3/************************************************************************************************
4 * @file bootloader_can_datagram.h
5 *
6 * @brief Header file for the CAN datagram in the bootloader
7 *
8 * @date 2025-01-08
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17
18/* Intra-component Headers */
19#include "bootloader_can.h"
20#include "bootloader_error.h"
21
29#define ACK 0U
30
32#define NACK 1U
33
37typedef enum {
45
49typedef struct {
55 union {
59 struct {
60 uint16_t node_ids;
61 uint32_t data_len;
62 } start;
63
67 struct {
68 uint16_t sequence_num;
69 uint32_t crc32;
70 } sequencing;
71
75 struct {
76 uint8_t *data;
77 } data;
78
82 struct {
83 uint16_t node_ids;
84 } jump_app;
85
89 struct {
90 uint8_t ack_status;
92 } ack;
93 } payload;
95
103BootloaderDatagram deserialize_datagram(Boot_CanMessage *msg, uint16_t *target_nodes);
104
110void send_ack_datagram(bool ack, BootloaderError error);
111
BootloaderDatagram deserialize_datagram(Boot_CanMessage *msg, uint16_t *target_nodes)
Deserialize an incoming CAN message.
Definition: bootloader_can_datagram.c:17
void send_ack_datagram(bool ack, BootloaderError error)
Send Bootloader ACK/NACK message over CAN.
Definition: bootloader_can_datagram.c:23
BootloaderCanID
Bootloader reserved CAN arbitration IDs.
Definition: bootloader_can_datagram.h:37
BootloaderError
Bootloader error definitions.
Definition: bootloader_error.h:28
@ BOOTLOADER_CAN_JUMP_BOOTLOADER
Definition: bootloader_can_datagram.h:43
@ BOOTLOADER_CAN_FLASH_ID
Definition: bootloader_can_datagram.h:39
@ BOOTLOADER_CAN_JUMP_APPLICATION_ID
Definition: bootloader_can_datagram.h:40
@ BOOTLOADER_CAN_SEQUENCING_ID
Definition: bootloader_can_datagram.h:38
@ BOOTLOADER_CAN_ACK_ID
Definition: bootloader_can_datagram.h:41
@ BOOTLOADER_CAN_START_ID
Definition: bootloader_can_datagram.h:42
CAN message structure.
Definition: bootloader_can.h:72
Datagram message definition.
Definition: bootloader_can_datagram.h:49
uint32_t data_len
Definition: bootloader_can_datagram.h:61
uint32_t crc32
Definition: bootloader_can_datagram.h:69
uint16_t sequence_num
Definition: bootloader_can_datagram.h:68
uint16_t bootloader_error
Definition: bootloader_can_datagram.h:91
uint8_t ack_status
Definition: bootloader_can_datagram.h:90
uint8_t * data
Definition: bootloader_can_datagram.h:76
uint16_t node_ids
Definition: bootloader_can_datagram.h:60
uint8_t datagram_type_id
Definition: bootloader_can_datagram.h:50