Skip to content

Commit

Permalink
2.5 continue
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Jun 12, 2024
1 parent c6c49fa commit 8ea9c2a
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 68 deletions.
6 changes: 3 additions & 3 deletions board/boards/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ struct board {
#define HW_TYPE_WHITE_PANDA 1U
#define HW_TYPE_GREY_PANDA 2U
#define HW_TYPE_BLACK_PANDA 3U
#define HW_TYPE_PEDAL 4U
// #define HW_TYPE_PEDAL 4U //depreciated
#define HW_TYPE_UNO 5U
#define HW_TYPE_DOS 6U
#define HW_TYPE_RED_PANDA 7U
#define HW_TYPE_RED_PANDA_V2 8U
// #define HW_TYPE_RED_PANDA_V2 8U //deprecated
#define HW_TYPE_TRES 9U
#define HW_TYPE_CUATRO 10U

Expand All @@ -65,7 +65,7 @@ struct board {
#define LED_BLUE 2U

// USB power modes (from cereal.log.health)
#define USB_POWER_NONE 0U
#define USB_POWER_NONE 0U // cppcheck-suppress misra-c2012-2.5
#define USB_POWER_CLIENT 1U
#define USB_POWER_CDP 2U
#define USB_POWER_DCP 3U
Expand Down
2 changes: 1 addition & 1 deletion board/drivers/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define PULL_UP 1
#define PULL_DOWN 2

#define OUTPUT_TYPE_PUSH_PULL 0U
// #define OUTPUT_TYPE_PUSH_PULL 0U // Unused
#define OUTPUT_TYPE_OPEN_DRAIN 1U

void set_gpio_mode(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) {
Expand Down
33 changes: 11 additions & 22 deletions board/drivers/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ void refresh_can_tx_slots_available(void);
// **** supporting defines ****

#define USB_REQ_GET_STATUS 0x00
#define USB_REQ_CLEAR_FEATURE 0x01
#define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_CLEAR_FEATURE 0x01 // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_REQ_SET_FEATURE 0x03 // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SET_DESCRIPTOR 0x07 // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_REQ_GET_CONFIGURATION 0x08 // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_GET_INTERFACE 0x0A // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
#define USB_REQ_SYNCH_FRAME 0x0C // cppcheck-suppress misra-c2012-2.5 ; unused

#define USB_DESC_TYPE_DEVICE 0x01
#define USB_DESC_TYPE_CONFIGURATION 0x02
#define USB_DESC_TYPE_STRING 0x03
#define USB_DESC_TYPE_INTERFACE 0x04
#define USB_DESC_TYPE_ENDPOINT 0x05
#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07 // cppcheck-suppress misra-c2012-2.5 ; unused
#define USB_DESC_TYPE_BINARY_OBJECT_STORE 0x0f

// offsets for configuration strings
Expand All @@ -60,24 +60,13 @@ void refresh_can_tx_slots_available(void);
#define STRING_OFFSET_ICONFIGURATION 0x04
#define STRING_OFFSET_IINTERFACE 0x05

// WebUSB requests
#define WEBUSB_REQ_GET_URL 0x02

// WebUSB types
#define WEBUSB_DESC_TYPE_URL 0x03
#define WEBUSB_URL_SCHEME_HTTPS 0x01
#define WEBUSB_URL_SCHEME_HTTP 0x00

// WinUSB requests
#define WINUSB_REQ_GET_COMPATID_DESCRIPTOR 0x04
#define WINUSB_REQ_GET_EXT_PROPS_OS 0x05
#define WINUSB_REQ_GET_DESCRIPTOR 0x07

#define STS_GOUT_NAK 1
#define STS_DATA_UPDT 2
#define STS_XFER_COMP 3
#define STS_SETUP_COMP 4
#define STS_SETUP_UPDT 6
#define STS_DATA_UPDT 2
#define STS_SETUP_UPDT 6

uint8_t response[USBPACKET_MAX_SIZE];

Expand All @@ -88,8 +77,8 @@ uint8_t response[USBPACKET_MAX_SIZE];
#define DSCR_DEVICE_LEN 18

// endpoint types
#define ENDPOINT_TYPE_CONTROL 0
#define ENDPOINT_TYPE_ISO 1
// #define ENDPOINT_TYPE_CONTROL 0 // unused
// #define ENDPOINT_TYPE_ISO 1 // unused
#define ENDPOINT_TYPE_BULK 2
#define ENDPOINT_TYPE_INT 3

Expand Down
24 changes: 12 additions & 12 deletions board/faults.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
#define FAULT_INTERRUPT_RATE_CAN_2 (1UL << 3)
#define FAULT_INTERRUPT_RATE_CAN_3 (1UL << 4)
#define FAULT_INTERRUPT_RATE_TACH (1UL << 5)
#define FAULT_INTERRUPT_RATE_GMLAN (1UL << 6) // deprecated
#define FAULT_INTERRUPT_RATE_GMLAN (1UL << 6) // cppcheck-suppress misra-c2012-2.5 ; unused - deprecated
#define FAULT_INTERRUPT_RATE_INTERRUPTS (1UL << 7)
#define FAULT_INTERRUPT_RATE_SPI_DMA (1UL << 8)
#define FAULT_INTERRUPT_RATE_SPI_CS (1UL << 9)
#define FAULT_INTERRUPT_RATE_UART_1 (1UL << 10)
#define FAULT_INTERRUPT_RATE_UART_2 (1UL << 11)
#define FAULT_INTERRUPT_RATE_UART_3 (1UL << 12)
#define FAULT_INTERRUPT_RATE_UART_5 (1UL << 13)
#define FAULT_INTERRUPT_RATE_UART_DMA (1UL << 14)
#define FAULT_INTERRUPT_RATE_SPI_CS (1UL << 9) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_UART_1 (1UL << 10) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_UART_2 (1UL << 11) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_UART_3 (1UL << 12) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_UART_5 (1UL << 13) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_UART_DMA (1UL << 14) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_USB (1UL << 15)
#define FAULT_INTERRUPT_RATE_TIM1 (1UL << 16)
#define FAULT_INTERRUPT_RATE_TIM3 (1UL << 17)
#define FAULT_INTERRUPT_RATE_TIM1 (1UL << 16) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_TIM3 (1UL << 17) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_REGISTER_DIVERGENT (1UL << 18)
#define FAULT_INTERRUPT_RATE_KLINE_INIT (1UL << 19)
#define FAULT_INTERRUPT_RATE_CLOCK_SOURCE (1UL << 20)
#define FAULT_INTERRUPT_RATE_KLINE_INIT (1UL << 19) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_CLOCK_SOURCE (1UL << 20) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_TICK (1UL << 21)
#define FAULT_INTERRUPT_RATE_EXTI (1UL << 22)
#define FAULT_INTERRUPT_RATE_EXTI (1UL << 22) // cppcheck-suppress misra-c2012-2.5 ; unused
#define FAULT_INTERRUPT_RATE_SPI (1UL << 23)
#define FAULT_INTERRUPT_RATE_UART_7 (1UL << 24)
#define FAULT_SIREN_MALFUNCTION (1UL << 25)
Expand Down
3 changes: 1 addition & 2 deletions board/safety/safety_mazda.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#define MAZDA_ENGINE_DATA 0x202
#define MAZDA_PEDALS 0x165

// CAN bus numbers
// CAN bus numbers - main 0, aux 1, camera 2
#define MAZDA_MAIN 0
#define MAZDA_AUX 1
#define MAZDA_CAM 2

const SteeringLimits MAZDA_STEERING_LIMITS = {
Expand Down
1 change: 0 additions & 1 deletion board/safety/safety_subaru.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const LongitudinalLimits SUBARU_LONG_LIMITS = {
#define MSG_SUBARU_Wheel_Speeds 0x13a

#define MSG_SUBARU_ES_LKAS 0x122
#define MSG_SUBARU_ES_LKAS_ANGLE 0x124
#define MSG_SUBARU_ES_Brake 0x220
#define MSG_SUBARU_ES_Distance 0x221
#define MSG_SUBARU_ES_Status 0x222
Expand Down
6 changes: 0 additions & 6 deletions board/safety_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,6 @@ struct sample_t angle_meas; // last 6 steer angles/curvatures
// If using this flag, make sure to communicate to your users that a stock safety feature is now disabled.
#define ALT_EXP_DISABLE_STOCK_AEB 2

// If using this flag, be aware that harder braking is more likely to lead to rear endings,
// and that alone this flag doesn't make braking compliant because there's also a time element.
// Setting this flag is used for allowing the full -5.0 to +4.0 m/s^2 at lower speeds
// See ISO 15622:2018 for more information.
#define ALT_EXP_RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX 8

// This flag allows AEB to be commanded from openpilot.
#define ALT_EXP_ALLOW_AEB 16

Expand Down
5 changes: 0 additions & 5 deletions board/stm32f4/llbxcan.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Flasher and pedal use raw mailbox access
#define GET_MAILBOX_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0xFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU))
#define GET_MAILBOX_BYTES_04(msg) ((msg)->RDLR)
#define GET_MAILBOX_BYTES_48(msg) ((msg)->RDHR)

// SAE 2284-3 : minimum 16 tq, SJW 3, sample point at 81.3%
#define CAN_QUANTA 16U
#define CAN_SEQ1 12U
Expand Down
3 changes: 0 additions & 3 deletions board/stm32f4/lluart.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ void uart_tx_ring(uart_ring *q){
EXIT_CRITICAL();
}

// This read after reading SR clears all error interrupts. We don't want compiler warnings, nor optimizations
#define UART_READ_DR(uart) volatile uint8_t t = (uart)->DR; UNUSED(t);


// ***************************** Hardware setup *****************************

Expand Down
2 changes: 1 addition & 1 deletion board/stm32f4/llusb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USB_OTG_GlobalTypeDef *USBx = USB_OTG_FS;

#define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE))
// #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE))
#define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE))
#define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
#define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
Expand Down
4 changes: 2 additions & 2 deletions board/stm32f4/stm32f4_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include "inc/stm32f4xx_hal_gpio_ex.h"
#define MCU_IDCODE 0x463U

#ifdef BOOTSTUB
// from the linker script
#define APP_START_ADDRESS 0x8004000U
#endif

#define CORE_FREQ 96U // in MHz
#define APB1_FREQ (CORE_FREQ/2U)
Expand All @@ -28,8 +30,6 @@
#define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn
#define INTERRUPT_TIMER TIM6

#define IND_WDG IWDG

#define PROVISION_CHUNK_ADDRESS 0x1FFF79E0U
#define DEVICE_SERIAL_NUMBER_ADDRESS 0x1FFF79C0U

Expand Down
3 changes: 0 additions & 3 deletions board/stm32h7/llfdcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
#define CAN_SEG2(tq, sp) ((tq) * (100U - (sp)) / 100U)

// FDCAN core settings
#define FDCAN_MESSAGE_RAM_SIZE 0x2800UL
#define FDCAN_START_ADDRESS 0x4000AC00UL
#define FDCAN_OFFSET 3384UL // bytes for each FDCAN module, equally
#define FDCAN_OFFSET_W 846UL // words for each FDCAN module, equally
#define FDCAN_END_ADDRESS 0x4000D3FCUL // Message RAM has a width of 4 bytes

// FDCAN_RX_FIFO_0_EL_CNT + FDCAN_TX_FIFO_EL_CNT can't exceed 47 elements (47 * 72 bytes = 3,384 bytes) per FDCAN module

Expand All @@ -32,7 +30,6 @@
#define FDCAN_TX_FIFO_HEAD_SIZE 8UL // bytes
#define FDCAN_TX_FIFO_DATA_SIZE 64UL // bytes
#define FDCAN_TX_FIFO_EL_SIZE (FDCAN_TX_FIFO_HEAD_SIZE + FDCAN_TX_FIFO_DATA_SIZE)
#define FDCAN_TX_FIFO_EL_W_SIZE (FDCAN_TX_FIFO_EL_SIZE / 4UL)
#define FDCAN_TX_FIFO_OFFSET (FDCAN_RX_FIFO_0_OFFSET + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_W_SIZE))

#define CAN_NAME_FROM_CANIF(CAN_DEV) (((CAN_DEV)==FDCAN1) ? "FDCAN1" : (((CAN_DEV) == FDCAN2) ? "FDCAN2" : "FDCAN3"))
Expand Down
2 changes: 1 addition & 1 deletion board/stm32h7/llusb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USB_OTG_GlobalTypeDef *USBx = USB_OTG_HS;

#define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE))
// #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE))
#define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE))
#define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
#define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
Expand Down
6 changes: 1 addition & 5 deletions board/stm32h7/stm32h7_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include "inc/stm32h7xx_hal_gpio_ex.h"
#define MCU_IDCODE 0x483U

// from the linker script
#define APP_START_ADDRESS 0x8020000U

#define CORE_FREQ 240U // in Mhz
//APB1 - 120Mhz, APB2 - 120Mhz
#define APB1_FREQ (CORE_FREQ/4U)
Expand Down Expand Up @@ -41,8 +38,6 @@ separate IRQs for RX and TX.
#define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn
#define INTERRUPT_TIMER TIM6

#define IND_WDG IWDG1

#define PROVISION_CHUNK_ADDRESS 0x080FFFE0U
#define DEVICE_SERIAL_NUMBER_ADDRESS 0x080FFFC0U

Expand All @@ -52,6 +47,7 @@ separate IRQs for RX and TX.
#ifndef BOOTSTUB
#include "main_declarations.h"
#else
#define APP_START_ADDRESS 0x8020000U // from the linker script
#include "bootstub_declarations.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Panda:
HW_TYPE_WHITE_PANDA = b'\x01'
HW_TYPE_GREY_PANDA = b'\x02'
HW_TYPE_BLACK_PANDA = b'\x03'
HW_TYPE_PEDAL = b'\x04'
# HW_TYPE_PEDAL = b'\x04' # depreciated
HW_TYPE_UNO = b'\x05'
HW_TYPE_DOS = b'\x06'
HW_TYPE_RED_PANDA = b'\x07'
Expand Down

0 comments on commit 8ea9c2a

Please sign in to comment.