Skip to content

Commit 596e505

Browse files
committed
split out config deps
1 parent 17bdba1 commit 596e505

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+251
-133
lines changed

SConscript

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def build_project(project_name, project, extra_flags):
8383
'.',
8484
'..',
8585
panda_root,
86+
f"{panda_root}/include/",
87+
f"{panda_root}/include/board/",
8688
f"{panda_root}/board/",
8789
f"{panda_root}/../opendbc/safety/",
8890
]

board/bootstub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#define BOOTSTUB
22

33
#define VERS_TAG 0x53524556
4-
#define MIN_VERSION 2
4+
#define MIN_VERSION 2
55

66
// ********************* Includes *********************
7+
#include "platform_definitions.h"
78
#include "config.h"
9+
#include "stm_config.h"
810

911
#include "drivers/led.h"
1012
#include "drivers/pwm.h"

board/can_comms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* the overflow buffers are reset by a dedicated control transfer handler,
1212
which is sent by the host on each start of a connection.
1313
*/
14+
#include "drivers/spi_declarations.h"
1415

1516
typedef struct {
1617
uint32_t ptr;

board/comms_definitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma once
12
typedef struct {
23
uint8_t request;
34
uint16_t param1;

board/critical.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ********************* Critical section helpers *********************
44
uint8_t global_critical_depth = 0U;
55

6-
static volatile bool interrupts_enabled = false;
6+
volatile bool interrupts_enabled = false;
77

88
void enable_interrupts(void) {
99
interrupts_enabled = true;

board/critical_declarations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ void enable_interrupts(void);
55
void disable_interrupts(void);
66

77
extern uint8_t global_critical_depth;
8+
extern volatile bool interrupts_enabled;
89

910
#define ENTER_CRITICAL() \
1011
__disable_irq(); \

board/drivers/bxcan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "bxcan_declarations.h"
2+
#include "drivers/can_common_declarations.h"
23

34
// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE
45
// CAN2_TX, CAN2_RX0, CAN2_SCE

board/drivers/can_common.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#include "can_common_declarations.h"
2+
#include "safety.h"
3+
4+
#ifdef STM32H7
5+
// ITCM RAM and DTCM RAM are the fastest for Cortex-M7 core access
6+
__attribute__((section(".axisram"))) can_buffer(rx_q, CAN_RX_BUFFER_SIZE)
7+
__attribute__((section(".itcmram"))) can_buffer(tx1_q, CAN_TX_BUFFER_SIZE)
8+
__attribute__((section(".itcmram"))) can_buffer(tx2_q, CAN_TX_BUFFER_SIZE)
9+
#else
10+
can_buffer(rx_q, CAN_RX_BUFFER_SIZE)
11+
can_buffer(tx1_q, CAN_TX_BUFFER_SIZE)
12+
can_buffer(tx2_q, CAN_TX_BUFFER_SIZE)
13+
#endif
14+
can_buffer(tx3_q, CAN_TX_BUFFER_SIZE)
215

316
uint32_t safety_tx_blocked = 0;
417
uint32_t safety_rx_invalid = 0;
@@ -17,25 +30,6 @@ int can_silent = ALL_CAN_SILENT;
1730
bool can_loopback = false;
1831

1932
// ********************* instantiate queues *********************
20-
#define can_buffer(x, size) \
21-
static CANPacket_t elems_##x[size]; \
22-
extern can_ring can_##x; \
23-
can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = (size), .elems = (CANPacket_t *)&(elems_##x) };
24-
25-
#define CAN_RX_BUFFER_SIZE 4096U
26-
#define CAN_TX_BUFFER_SIZE 416U
27-
28-
#ifdef STM32H7
29-
// ITCM RAM and DTCM RAM are the fastest for Cortex-M7 core access
30-
__attribute__((section(".axisram"))) can_buffer(rx_q, CAN_RX_BUFFER_SIZE)
31-
__attribute__((section(".itcmram"))) can_buffer(tx1_q, CAN_TX_BUFFER_SIZE)
32-
__attribute__((section(".itcmram"))) can_buffer(tx2_q, CAN_TX_BUFFER_SIZE)
33-
#else
34-
can_buffer(rx_q, CAN_RX_BUFFER_SIZE)
35-
can_buffer(tx1_q, CAN_TX_BUFFER_SIZE)
36-
can_buffer(tx2_q, CAN_TX_BUFFER_SIZE)
37-
#endif
38-
can_buffer(tx3_q, CAN_TX_BUFFER_SIZE)
3933

4034
// FIXME:
4135
// cppcheck-suppress misra-c2012-9.3

board/drivers/can_common_declarations.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#pragma once
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
#include "can.h"
5+
#include "health.h"
6+
#include "safety.h"
27

38
typedef struct {
49
volatile uint32_t w_ptr;
@@ -7,6 +12,18 @@ typedef struct {
712
CANPacket_t *elems;
813
} can_ring;
914

15+
#define can_buffer(x, size) \
16+
static CANPacket_t elems_##x[size]; \
17+
can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = (size), .elems = (CANPacket_t *)&(elems_##x) };
18+
19+
#define CAN_RX_BUFFER_SIZE 4096U
20+
#define CAN_TX_BUFFER_SIZE 416U
21+
22+
extern can_ring can_rx_q;
23+
extern can_ring can_tx1_q;
24+
extern can_ring can_tx2_q;
25+
extern can_ring can_tx3_q;
26+
1027
typedef struct {
1128
uint8_t bus_lookup;
1229
uint8_t can_num_lookup;
@@ -75,14 +92,17 @@ extern bus_config_t bus_config[BUS_CONFIG_ARRAY_SIZE];
7592
#define CAN_NUM_FROM_BUS_NUM(num) (bus_config[num].can_num_lookup)
7693

7794
void can_init_all(void);
95+
void can_clear(can_ring *q);
7896
void can_set_orientation(bool flipped);
7997
#ifdef PANDA_JUNGLE
8098
void can_set_forwarding(uint8_t from, uint8_t to);
8199
#endif
82100
void ignition_can_hook(CANPacket_t *to_push);
83101
bool can_tx_check_min_slots_free(uint32_t min);
84-
uint8_t calculate_checksum(const uint8_t *dat, uint32_t len);
85-
void can_set_checksum(CANPacket_t *packet);
102+
extern uint8_t calculate_checksum(const uint8_t *dat, uint32_t len);
103+
extern void can_set_checksum(CANPacket_t *packet);
86104
bool can_check_checksum(CANPacket_t *packet);
87105
void can_send(CANPacket_t *to_push, uint8_t bus_number, bool skip_tx_hook);
88106
bool is_speed_valid(uint32_t speed, const uint32_t *all_speeds, uint8_t len);
107+
108+
extern bool safety_tx_hook(CANPacket_t *to_send);

board/drivers/fan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "fan_declarations.h"
2+
#include "utils.h"
23

34
struct fan_state_t fan_state;
45

0 commit comments

Comments
 (0)