From 76fd7a39178d2ffb6b04dbb8b60add1f9aa42170 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Sat, 4 Apr 2020 22:28:41 +0200 Subject: [PATCH] Added COMM_SET_CAN_MODE and added support for HW75_300_R3 --- commands.c | 23 +++++++++++++++++++++++ conf_general.h | 3 ++- datatypes.h | 6 +++++- hwconf/hw_75_300.h | 12 +++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/commands.c b/commands.c index a855651e..35ccfcd0 100644 --- a/commands.c +++ b/commands.c @@ -989,6 +989,29 @@ void commands_process_packet(unsigned char *data, unsigned int len, } } break; + case COMM_SET_CAN_MODE: { + int32_t ind = 0; + bool store = data[ind++]; + bool ack = data[ind++]; + bool mode = data[ind++]; + + appconf = *app_get_configuration(); + appconf.can_mode = mode; + + if (store) { + conf_general_store_app_configuration(&appconf); + } + + app_set_configuration(&appconf); + + if (ack) { + ind = 0; + uint8_t send_buffer[50]; + send_buffer[ind++] = packet_id; + reply_func(send_buffer, ind); + } + } break; + // Blocking commands. Only one of them runs at any given time, in their // own thread. If other blocking commands come before the previous one has // finished, they are discarded. diff --git a/conf_general.h b/conf_general.h index 8f127c26..4a410f5b 100644 --- a/conf_general.h +++ b/conf_general.h @@ -98,7 +98,8 @@ //#define HW75_300_VEDDER_FIRST_PCB // Second revision with separate UART for NRF51 -#define HW75_300_REV_2 +//#define HW75_300_REV_2 +#define HW75_300_REV_3 //#define HW_SOURCE "hw_75_300.c" //#define HW_HEADER "hw_75_300.h" diff --git a/datatypes.h b/datatypes.h index 5ba58940..9497d6d8 100644 --- a/datatypes.h +++ b/datatypes.h @@ -756,7 +756,11 @@ typedef enum { COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO, COMM_BM_WRITE_FLASH_LZO, COMM_SET_CURRENT_REL, - COMM_CAN_FWD_FRAME + COMM_CAN_FWD_FRAME, + COMM_SET_BATTERY_CUT, + COMM_SET_BLE_NAME, + COMM_SET_BLE_PIN, + COMM_SET_CAN_MODE } COMM_PACKET_ID; // CAN commands diff --git a/hwconf/hw_75_300.h b/hwconf/hw_75_300.h index 5534259d..09050045 100644 --- a/hwconf/hw_75_300.h +++ b/hwconf/hw_75_300.h @@ -20,7 +20,9 @@ #ifndef HW_75_300_H_ #define HW_75_300_H_ -#ifdef HW75_300_REV_2 +#ifdef HW75_300_REV_3 +#define HW_NAME "75_300_R3" +#elif defined(HW75_300_REV_2) #define HW_NAME "75_300_R2" #else #define HW_NAME "75_300" @@ -197,6 +199,14 @@ #define HW_UART_P_RX_PIN 11 #endif +#ifdef HW75_300_REV_3 +// NRF SWD +#define NRF5x_SWDIO_GPIO GPIOA +#define NRF5x_SWDIO_PIN 15 +#define NRF5x_SWCLK_GPIO GPIOB +#define NRF5x_SWCLK_PIN 3 +#endif + // ICU Peripheral for servo decoding #define HW_USE_SERVO_TIM4 #define HW_ICU_TIMER TIM4