Compare commits
5 Commits
main
...
integratio
Author | SHA1 | Date | |
---|---|---|---|
22e24b38b5 | |||
63e3333260 | |||
dc8e0c806a | |||
75950a226d | |||
2afdfa8293 |
@ -47,6 +47,7 @@ extern "C" {
|
|||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EM */
|
/* USER CODE BEGIN EM */
|
||||||
|
|
||||||
|
void Error_Handler_Led(uint8_t err);
|
||||||
/* USER CODE END EM */
|
/* USER CODE END EM */
|
||||||
|
|
||||||
/* Exported functions prototypes ---------------------------------------------*/
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
// CHOOSE ONE, comment the other or comment both and use -D SN_FRONT
|
// CHOOSE ONE, comment the other or comment both and use -D SN_FRONT
|
||||||
//#define SN_FRONT
|
//#define SN_FRONT
|
||||||
#define SN_REAR
|
#define SN_REAR
|
||||||
|
// #define DEBUG
|
||||||
|
|
||||||
#ifdef SN_FRONT
|
#if (defined(SN_FRONT) && defined(SN_REAR)) || \
|
||||||
#ifdef SN_REAR
|
(defined(SN_FRONT) && defined(DEBUG)) || \
|
||||||
#error "Choose to either #define SN_FRONT or SN_REAR, not both!"
|
(defined(SN_REAR) && defined(DEBUG))
|
||||||
#endif
|
#error "Choose only one of #define SN_FRONT, #define SN_REAR, or #define DEBUG!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -20,12 +21,12 @@ static struct {
|
|||||||
GPIO_TypeDef* port;
|
GPIO_TypeDef* port;
|
||||||
uint16_t pin;
|
uint16_t pin;
|
||||||
} DIO_PIN_MAP[NUM_DIO_PINS] = {
|
} DIO_PIN_MAP[NUM_DIO_PINS] = {
|
||||||
/* 0 */ { .port = D1_IC_GPIO_Port, .pin = D1_IC_Pin},
|
/* 0 */ { .port = D5_GPIO_Port, .pin = D5_Pin},
|
||||||
/* 1 */ { .port = D2_GPIO_Port, .pin = D2_Pin},
|
/* 1 */ { .port = D6_GPIO_Port, .pin = D6_Pin},
|
||||||
/* 2 */ { .port = D3_GPIO_Port, .pin = D3_Pin},
|
/* 2 */ { .port = D4_IC_GPIO_Port, .pin = D4_IC_Pin},
|
||||||
/* 3 */ { .port = D4_IC_GPIO_Port, .pin = D4_IC_Pin},
|
/* 3 */ { .port = D3_GPIO_Port, .pin = D3_Pin},
|
||||||
/* 4 */ { .port = D5_GPIO_Port, .pin = D5_Pin},
|
/* 4 */ { .port = D2_GPIO_Port, .pin = D2_Pin},
|
||||||
/* 5 */ { .port = D6_GPIO_Port, .pin = D6_Pin},
|
/* 5 */ { .port = D1_IC_GPIO_Port, .pin = D1_IC_Pin},
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -189,6 +190,58 @@ static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
|
||||||
|
{
|
||||||
|
.can_id = 0x044, .dlc = 6, .num_signals = 9, .period = 100, .signals = {
|
||||||
|
{ .type = DIN, .channel = L9, .start = 0, .length = 1, .factor = 1., .name = "" },
|
||||||
|
{ .type = DIN, .channel = LA, .start = 1, .length = 1, .factor = 1., .name = "" },
|
||||||
|
{ .type = DIN, .channel = LC, .start = 2, .length = 1, .factor = 1., .name = "" },
|
||||||
|
{ .type = DIN, .channel = R5, .start = 3, .length = 1, .factor = 1., .name = "" },
|
||||||
|
{ .type = DIN, .channel = R6, .start = 4, .length = 1, .factor = 1., .name = "" },
|
||||||
|
{ .type = DIN, .channel = R7, .start = 5, .length = 1, .factor = 1., .name = "" },
|
||||||
|
|
||||||
|
{ .type = AIN, .channel = L1, .start = 6+12*0, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L2, .start = 6+12*1, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L3, .start = 6+12*2, .length = 12, .factor = 1., .name = "" },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.can_id = 0x045, .dlc = 8, .num_signals = 5, .period = 100, .signals = {
|
||||||
|
{ .type = AIN, .channel = L4, .start = 12*0, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L5, .start = 12*1, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L6, .start = 12*2, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L7, .start = 12*3, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = L8, .start = 12*4, .length = 12, .factor = 1., .name = "" },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.can_id = 0x046, .dlc = 8, .num_signals = 5, .period = 100, .signals = {
|
||||||
|
{ .type = AIN, .channel = R9, .start = 12*0, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = RA, .start = 12*1, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = RB, .start = 12*2, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = RC, .start = 12*3, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = RD, .start = 12*4, .length = 12, .factor = 1., .name = "" },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.can_id = 0x047, .dlc = 5, .num_signals = 3, .period = 100, .signals = {
|
||||||
|
{ .type = AIN, .channel = RE, .start = 12*0, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = RF, .start = 12*1, .length = 12, .factor = 1., .name = "" },
|
||||||
|
{ .type = AIN, .channel = R0, .start = 12*2, .length = 12, .factor = 1., .name = "" },
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CAN_PWM_DC_ID 0x0DA // UNUSED
|
||||||
|
#define CAN_PWM_CONF_ID 0x0DB // UNUSED
|
||||||
|
#define CAN_PWM_BASE_ID CAN_PWM_DC_ID
|
||||||
|
#define CAN_PWM_FILTER_MASK 0x7FE // Match both
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* user needs
|
/* user needs
|
||||||
TIM_HandleTypeDef* PWM_TIM_MAP[3] = {&htim1, &htim4, &htim3};
|
TIM_HandleTypeDef* PWM_TIM_MAP[3] = {&htim1, &htim4, &htim3};
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "mappings.h"
|
#include "mappings.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
@ -41,6 +40,7 @@
|
|||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
#define TIM_BASE_FREQ 96000000UL
|
#define TIM_BASE_FREQ 96000000UL
|
||||||
|
#define WSS_HISTORY_SIZE 10
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@ -51,24 +51,25 @@
|
|||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
unsigned int tx_counter;
|
unsigned int mscounter;
|
||||||
bool adc_conv_cplt;
|
unsigned int setup_complete;
|
||||||
|
|
||||||
FDCAN_HandleTypeDef *hMainCAN, *hPeriCAN;
|
FDCAN_HandleTypeDef *hMainCAN, *hPeriCAN;
|
||||||
FDCAN_TxHeaderTypeDef txHeader;
|
FDCAN_TxHeaderTypeDef txHeader;
|
||||||
|
|
||||||
// Declare buffer in AXI SRAM
|
/* Declare buffer in D1 domain SRAM */
|
||||||
static uint16_t adc_values[NUM_ADC_PINS];
|
static uint16_t adc_values[NUM_ADC_PINS];
|
||||||
static uint8_t dio_values[NUM_DIO_PINS];
|
static uint8_t dio_values[NUM_DIO_PINS];
|
||||||
|
|
||||||
static uint16_t filtered_values[NUM_ADC_PINS];
|
|
||||||
|
|
||||||
// See mappings.h pwm_tim_t
|
// See mappings.h pwm_tim_t
|
||||||
TIM_HandleTypeDef* PWM_TIM_MAP[3] = {&htim1, &htim4, &htim3};
|
TIM_HandleTypeDef* PWM_TIM_MAP[3] = {&htim1, &htim4, &htim3};
|
||||||
|
|
||||||
static uint8_t pwm_ch_active[8];
|
static uint8_t pwm_ch_active[8];
|
||||||
|
|
||||||
static uint16_t wss_flanks[2];
|
static uint16_t wss_flanks[2];
|
||||||
|
static uint16_t wss_flanks_avg[2];
|
||||||
|
static uint8_t wss_flanks_history[2][WSS_HISTORY_SIZE];
|
||||||
|
static uint8_t wss_flanks_history_idx[2]; // index of the oldest entry (next to be overwritten)
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@ -81,9 +82,12 @@ static void MX_NVIC_Init(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
void send_latest_can() {
|
void loop_1kHz() {
|
||||||
|
|
||||||
tx_counter++;
|
if (!setup_complete)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mscounter++;
|
||||||
|
|
||||||
for (int di = 0; di < NUM_DIO_PINS; di++) {
|
for (int di = 0; di < NUM_DIO_PINS; di++) {
|
||||||
dio_values[di] = HAL_GPIO_ReadPin(
|
dio_values[di] = HAL_GPIO_ReadPin(
|
||||||
@ -99,7 +103,7 @@ void send_latest_can() {
|
|||||||
if (pktinfo->num_signals < 0)
|
if (pktinfo->num_signals < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tx_counter % pktinfo->period == 0) {
|
if (mscounter % pktinfo->period == 0) {
|
||||||
|
|
||||||
txHeader.Identifier = pktinfo->can_id;
|
txHeader.Identifier = pktinfo->can_id;
|
||||||
txHeader.DataLength = pktinfo->dlc;
|
txHeader.DataLength = pktinfo->dlc;
|
||||||
@ -115,11 +119,15 @@ void send_latest_can() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AIN:
|
case AIN:
|
||||||
value = signal->factor * filtered_values[signal->channel];
|
value = signal->factor * adc_values[signal->channel];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIN:
|
case FIN:
|
||||||
value = wss_flanks[signal->channel];
|
uint8_t oldest_hist_idx = wss_flanks_history_idx[signal->channel];
|
||||||
|
// subtract oldest entry from avg
|
||||||
|
wss_flanks_avg[signal->channel] -= wss_flanks_history[signal->channel][oldest_hist_idx];
|
||||||
|
// overwrite oldest history entry with new value and reset counter
|
||||||
|
wss_flanks_history[signal->channel][oldest_hist_idx] = wss_flanks[signal->channel];
|
||||||
wss_flanks[signal->channel] = 0;
|
wss_flanks[signal->channel] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -132,30 +140,20 @@ void send_latest_can() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HAL_FDCAN_AddMessageToTxFifoQ(hMainCAN, &txHeader, (uint8_t*) &txData) != HAL_OK)
|
if (HAL_FDCAN_AddMessageToTxFifoQ(hMainCAN, &txHeader, (uint8_t*) &txData) != HAL_OK) {
|
||||||
Error_Handler();
|
if(HAL_FDCAN_GetError(hMainCAN) != HAL_FDCAN_ERROR_FIFO_FULL) {
|
||||||
|
Error_Handler_Led(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx_counter >= 256) {
|
if (mscounter >= 500) {
|
||||||
tx_counter = 0;
|
mscounter = 0;
|
||||||
HAL_GPIO_TogglePin(STATUS_G_GPIO_Port, STATUS_G_Pin);
|
HAL_GPIO_TogglePin(STATUS_G_GPIO_Port, STATUS_G_Pin);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void filter_adc() {
|
|
||||||
for (size_t i = 0; i < NUM_TX_PKT; i++){
|
|
||||||
float alpha = 1 / CAN_SIGNAL_MAP[i].period; // TODO: check if it smoothes too much
|
|
||||||
|
|
||||||
for (size_t j = 0; i < CAN_SIGNAL_MAP[i].num_signals; j++) {
|
|
||||||
if(CAN_SIGNAL_MAP[i].signals[j].type != AIN)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
uint8_t ch_index = CAN_SIGNAL_MAP[i].signals[j].channel;
|
|
||||||
filtered_values[ch_index] = (alpha * adc_values[ch_index]) + ((1 - alpha) * filtered_values[ch_index]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
@ -207,10 +205,10 @@ int main(void)
|
|||||||
hPeriCAN = &hfdcan2;
|
hPeriCAN = &hfdcan2;
|
||||||
|
|
||||||
if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
|
if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(2);
|
||||||
|
|
||||||
if (HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_values, NUM_ADC_PINS) != HAL_OK)
|
if (HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_values, NUM_ADC_PINS) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(2);
|
||||||
|
|
||||||
HAL_TIM_Base_Start_IT(&htim6);
|
HAL_TIM_Base_Start_IT(&htim6);
|
||||||
|
|
||||||
@ -227,11 +225,11 @@ int main(void)
|
|||||||
txHeader.DataLength = 8;
|
txHeader.DataLength = 8;
|
||||||
|
|
||||||
if (HAL_FDCAN_ActivateNotification(hMainCAN, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
|
if (HAL_FDCAN_ActivateNotification(hMainCAN, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(3);
|
||||||
|
|
||||||
if (HAL_FDCAN_ConfigGlobalFilter(hMainCAN, FDCAN_REJECT, FDCAN_REJECT,
|
if (HAL_FDCAN_ConfigGlobalFilter(hMainCAN, FDCAN_REJECT, FDCAN_REJECT,
|
||||||
FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE) != HAL_OK)
|
FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(3);
|
||||||
|
|
||||||
FDCAN_FilterTypeDef filter;
|
FDCAN_FilterTypeDef filter;
|
||||||
filter.IdType = FDCAN_STANDARD_ID;
|
filter.IdType = FDCAN_STANDARD_ID;
|
||||||
@ -242,10 +240,10 @@ int main(void)
|
|||||||
filter.FilterID2 = CAN_PWM_FILTER_MASK;
|
filter.FilterID2 = CAN_PWM_FILTER_MASK;
|
||||||
|
|
||||||
if (HAL_FDCAN_ConfigFilter(hMainCAN, &filter) != HAL_OK)
|
if (HAL_FDCAN_ConfigFilter(hMainCAN, &filter) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(5);
|
||||||
|
|
||||||
if (HAL_FDCAN_Start(hMainCAN) != HAL_OK)
|
if (HAL_FDCAN_Start(hMainCAN) != HAL_OK)
|
||||||
Error_Handler();
|
Error_Handler_Led(5);
|
||||||
|
|
||||||
// Init all channels as stopped
|
// Init all channels as stopped
|
||||||
memset(pwm_ch_active, 0, 8);
|
memset(pwm_ch_active, 0, 8);
|
||||||
@ -254,26 +252,24 @@ int main(void)
|
|||||||
HAL_TIM_IC_Start_IT(&htim8, TIM_CHANNEL_1);
|
HAL_TIM_IC_Start_IT(&htim8, TIM_CHANNEL_1);
|
||||||
HAL_TIM_IC_Start_IT(&htim8, TIM_CHANNEL_2);
|
HAL_TIM_IC_Start_IT(&htim8, TIM_CHANNEL_2);
|
||||||
|
|
||||||
tx_counter = 0;
|
mscounter = 0;
|
||||||
|
setup_complete = 1;
|
||||||
|
|
||||||
|
memset(wss_flanks, 0, sizeof(wss_flanks));
|
||||||
|
memset(wss_flanks_avg, 0, sizeof(wss_flanks));
|
||||||
|
memset(wss_flanks_history, 0, sizeof(wss_flanks_history));
|
||||||
|
memset(wss_flanks_history_idx, 0, sizeof(wss_flanks_history_idx));
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(adc_conv_cplt) {
|
|
||||||
adc_conv_cplt = false;
|
|
||||||
|
|
||||||
filter_adc();
|
|
||||||
|
|
||||||
send_latest_can();
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
|
//HAL_SuspendTick();
|
||||||
|
//HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
@ -317,7 +313,7 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitStruct.PLL.PLLFRACN = 0;
|
RCC_OscInitStruct.PLL.PLLFRACN = 0;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler_Led(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
@ -335,7 +331,7 @@ void SystemClock_Config(void)
|
|||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler_Led(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,13 +347,13 @@ static void MX_NVIC_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
/*void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
||||||
{
|
{
|
||||||
if (hadc->Instance == ADC1)
|
if (hadc->Instance == ADC1)
|
||||||
{
|
{
|
||||||
adc_conv_cplt = true;
|
__asm volatile ("NOP");
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||||
|
|
||||||
@ -366,7 +362,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
|||||||
if (htim != &htim6)
|
if (htim != &htim6)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Make timer 10kHz and dont trigger a function with it, for exiting WFI in main
|
loop_1kHz();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -476,6 +472,49 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||||||
HAL_ResumeTick();
|
HAL_ResumeTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Error_Handler_Led(uint8_t err) {
|
||||||
|
HAL_GPIO_WritePin(STATUS_R_GPIO_Port, STATUS_R_Pin, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_G_GPIO_Port, STATUS_G_Pin, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_B_GPIO_Port, STATUS_B_Pin, GPIO_PIN_RESET);
|
||||||
|
switch (err)
|
||||||
|
{
|
||||||
|
case 0: // red: general error
|
||||||
|
HAL_GPIO_WritePin(STATUS_R_GPIO_Port, STATUS_R_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // red blue: in 1 kHz loop
|
||||||
|
HAL_GPIO_WritePin(STATUS_R_GPIO_Port, STATUS_R_Pin, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_B_GPIO_Port, STATUS_B_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // blue: ADC calibration or DMA start
|
||||||
|
HAL_GPIO_WritePin(STATUS_B_GPIO_Port, STATUS_B_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // green blue: CAN notify and config gloabl filter
|
||||||
|
HAL_GPIO_WritePin(STATUS_B_GPIO_Port, STATUS_B_Pin, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_G_GPIO_Port, STATUS_G_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4: //red green: clock
|
||||||
|
HAL_GPIO_WritePin(STATUS_R_GPIO_Port, STATUS_R_Pin, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_G_GPIO_Port, STATUS_G_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5: // red green blue: CAN config filter and start
|
||||||
|
HAL_GPIO_WritePin(STATUS_R_GPIO_Port, STATUS_R_Pin, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_B_GPIO_Port, STATUS_B_Pin, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(STATUS_G_GPIO_Port, STATUS_G_Pin, GPIO_PIN_SET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
__disable_irq();
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
29
Software/debug_dbc_entries.txt
Normal file
29
Software/debug_dbc_entries.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
BO_ 68 Sensornode_Debug_1: 6 Sensornode_F
|
||||||
|
SG_ Sensornode_Debug_L9 : 0|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_LA : 1|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_LC : 2|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_R5 : 3|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_R6 : 4|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_R7 : 5|1@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L1 : 6|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L2 : 18|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L3 : 30|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
|
||||||
|
BO_ 69 Sensornode_Debug_2: 8 Sensornode_F
|
||||||
|
SG_ Sensornode_Debug_L4 : 0|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L5 : 12|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L6 : 24|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L7 : 36|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_L8 : 48|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
|
||||||
|
BO_ 70 Sensornode_Debug_3: 8 Sensornode_F
|
||||||
|
SG_ Sensornode_Debug_R9 : 0|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_RA : 12|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_RB : 24|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_RC : 36|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_RD : 48|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
|
||||||
|
BO_ 71 Sensornode_Debug_4: 5 Sensornode_F
|
||||||
|
SG_ Sensornode_Debug_RE : 0|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_RF : 12|12@1+ (1,0) [0|1] "" Vector__XXX
|
||||||
|
SG_ Sensornode_Debug_R0 : 24|12@1+ (1,0) [0|1] "" Vector__XXX
|
Loading…
x
Reference in New Issue
Block a user