Compare commits
	
		
			1 Commits
		
	
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c4849935c0 | 
@ -60,6 +60,9 @@ FDCAN_TxHeaderTypeDef txHeader;
 | 
			
		||||
// Declare buffer in AXI SRAM
 | 
			
		||||
static uint16_t adc_values[NUM_ADC_PINS];
 | 
			
		||||
static uint8_t  dio_values[NUM_DIO_PINS];
 | 
			
		||||
#ifdef SN_FRONT
 | 
			
		||||
static uint8_t  ls_values[2];
 | 
			
		||||
#endif /* SN_FRONT */
 | 
			
		||||
 | 
			
		||||
static uint16_t filtered_values[NUM_ADC_PINS];
 | 
			
		||||
 | 
			
		||||
@ -85,12 +88,23 @@ void send_latest_can() {
 | 
			
		||||
 | 
			
		||||
  tx_counter++;
 | 
			
		||||
 | 
			
		||||
  #if defined(SN_FRONT)
 | 
			
		||||
  memcpy(dio_values, ls_values, 2);
 | 
			
		||||
  memset(ls_values, 0, 2);
 | 
			
		||||
  for (int di = 2; di < NUM_DIO_PINS; di++) { //TODO: find way to make this dependent on mappings
 | 
			
		||||
    dio_values[di] = HAL_GPIO_ReadPin(
 | 
			
		||||
      DIO_PIN_MAP[di].port,
 | 
			
		||||
      DIO_PIN_MAP[di].pin
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  #elif defined(SN_REAR)
 | 
			
		||||
  for (int di = 0; di < NUM_DIO_PINS; di++) {
 | 
			
		||||
    dio_values[di] = HAL_GPIO_ReadPin(
 | 
			
		||||
      DIO_PIN_MAP[di].port,
 | 
			
		||||
      DIO_PIN_MAP[di].pin
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  #endif /* SN_FRONT */
 | 
			
		||||
 | 
			
		||||
  for (int pi = 0; pi < NUM_TX_PKT; pi++) {
 | 
			
		||||
 | 
			
		||||
@ -158,6 +172,16 @@ void filter_adc() {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef SN_FRONT
 | 
			
		||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
 | 
			
		||||
  if (GPIO_Pin == DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[0].channel].pin) {
 | 
			
		||||
    ls_values[1] = 1;
 | 
			
		||||
  } else if (GPIO_Pin == DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[1].channel].pin) {
 | 
			
		||||
    ls_values[0] = 1;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
#endif /* SN_FRONT */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -202,6 +226,36 @@ int main(void)
 | 
			
		||||
  /* Initialize interrupts */
 | 
			
		||||
  MX_NVIC_Init();
 | 
			
		||||
  /* USER CODE BEGIN 2 */
 | 
			
		||||
 | 
			
		||||
  // Enable Interrupts for Light Switch Pins
 | 
			
		||||
#ifdef SN_FRONT
 | 
			
		||||
  // check if pin name is "LS L"
 | 
			
		||||
  if (strcmp(CAN_SIGNAL_MAP[0].signals[0].name, "LS L") != 0
 | 
			
		||||
   || strcmp(CAN_SIGNAL_MAP[0].signals[1].name, "LS R") != 0
 | 
			
		||||
  ) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
  GPIO_InitStruct.Pin = CAN_SIGNAL_MAP[0].signals[0].channel;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[0].channel].port, &GPIO_InitStruct);
 | 
			
		||||
  GPIO_InitStruct.Pin = CAN_SIGNAL_MAP[0].signals[1].channel;
 | 
			
		||||
  HAL_GPIO_Init(DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[1].channel].port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  // Did not find a way to make this dependent on mappings,
 | 
			
		||||
  // since the EXTI lines are shared for pins 10-15
 | 
			
		||||
  // so i just error if the pins are not 10, 15
 | 
			
		||||
  if (DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[0].channel].pin != GPIO_PIN_10
 | 
			
		||||
   || DIO_PIN_MAP[CAN_SIGNAL_MAP[0].signals[1].channel].pin != GPIO_PIN_15
 | 
			
		||||
  ) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
 | 
			
		||||
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
 | 
			
		||||
#endif /* SN_FRONT */
 | 
			
		||||
  
 | 
			
		||||
  hMainCAN = &hfdcan1;
 | 
			
		||||
  hPeriCAN = &hfdcan2;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user