Add full automotive RTOS project

Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers,
middleware (CAN stack, diagnostics, safety), applications, board
support, build/test tooling, and documentation.
This commit is contained in:
root
2026-08-23 03:35:29 -04:00
parent f113bf0a05
commit ca13734bf0
151 changed files with 23945 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
/**
* @file can_nm.h
* @brief CAN Network Management (AUTOSAR-like) implementation
*/
#ifndef CAN_NM_H
#define CAN_NM_H
#include <stdint.h>
#include <stdbool.h>
#include "kernel.h"
#include "can_driver.h"
/* CAN NM Configuration */
#define CAN_NM_MAX_NODES 16
#define CAN_NM_MAX_NETWORKS 4
#define CAN_NM_MESSAGE_ID_BASE 0x400 /* Base ID for NM messages */
#define CAN_NM_DEFAULT_TIMEOUT_MS 2000
/* CAN NM States */
typedef enum {
CAN_NM_BUS_SLEEP = 0,
CAN_NM_PREPARE_BUS_SLEEP = 1,
CAN_NM_READY_SLEEP = 2,
CAN_NM_NORMAL_OPERATION = 3,
CAN_NM_REPEAT_MESSAGE = 4,
CAN_NM_SYNCHRONIZE = 5,
CAN_NM_OFFLINE = 6
} CanNmState_t;
/* CAN NM Message Types */
typedef enum {
CAN_NM_MSG_ALIVE = 0,
CAN_NM_MSG_RING = 1,
CAN_NM_MSG_LIMPHOME = 2,
CAN_NM_MSG_SLEEP_ACK = 3,
CAN_NM_MSG_SLEEP_CONF = 4
} CanNmMessageType_t;
/* CAN NM Configuration */
typedef struct {
uint8_t node_id;
uint8_t network_id;
uint32_t message_id;
uint32_t timeout_ms;
uint32_t repeat_message_time_ms;
bool is_coordinator;
uint8_t sleep_ack_timeout_ms;
} CanNmConfig_t;
/* CAN NM Node Information */
typedef struct {
uint8_t node_id;
bool is_present;
bool is_awake;
uint32_t last_message_time;
CanNmState_t state;
} CanNmNodeInfo_t;
/* CAN NM Callbacks */
typedef void (*CanNmNetworkStateChangedCallback_t)(CanNmState_t new_state);
typedef void (*CanNmNodeStateChangedCallback_t)(uint8_t node_id, bool is_awake);
typedef void (*CanNmBusSleepRequestCallback_t)(void);
typedef void (*CanNmWakeupIndicationCallback_t)(void);
/* CAN NM Functions */
KernelStatus_t can_nm_init(const CanNmConfig_t* config);
KernelStatus_t can_nm_deinit(void);
KernelStatus_t can_nm_start(void);
KernelStatus_t can_nm_stop(void);
KernelStatus_t can_nm_request_bus_sleep(void);
KernelStatus_t can_nm_network_release(void);
KernelStatus_t can_nm_network_request(void);
CanNmState_t can_nm_get_state(void);
KernelStatus_t can_nm_get_node_info(uint8_t node_id, CanNmNodeInfo_t* info);
KernelStatus_t can_nm_register_callbacks(
CanNmNetworkStateChangedCallback_t network_callback,
CanNmNodeStateChangedCallback_t node_callback,
CanNmBusSleepRequestCallback_t sleep_callback,
CanNmWakeupIndicationCallback_t wakeup_callback);
void can_nm_process_rx_message(const CanMessage_t* message);
void can_nm_main_function(void); /* Periodic processing */
bool can_nm_is_bus_awake(void);
#endif /* CAN_NM_H */