30 lines
636 B
C
30 lines
636 B
C
#include <stdint.h>
|
|
|
|
#include "can-halal.h"
|
|
#include "led.h"
|
|
#include "farbe.h"
|
|
#include "stm32f0xx_hal_adc.h"
|
|
#include "stm32f0xx_hal_tim.h"
|
|
|
|
extern TIM_HandleTypeDef htim2;
|
|
|
|
int16_t id = 0x200;
|
|
int32_t color = HEART_BEAT;
|
|
int32_t adcRes = 0;
|
|
|
|
void adc_init(ADC_HandleTypeDef* hadc){
|
|
HAL_ADCEx_Calibration_Start(hadc);
|
|
}
|
|
|
|
void adc_loop(ADC_HandleTypeDef* hadc){
|
|
HAL_ADC_Start_IT(hadc);
|
|
static uint8_t data[4];
|
|
ftcan_marshal_unsigned(data, adcRes, 4);
|
|
ftcan_transmit(id, data, sizeof(data));
|
|
|
|
blink(&htim2, color);
|
|
}
|
|
|
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){
|
|
adcRes = HAL_ADC_GetValue(hadc);
|
|
} |