sc8-gat-stand/gat_stand_fw/user/periph/adc.h

53 lines
1.1 KiB
C
Raw Normal View History

/*
* lightsense.h
*
* Created on: Oct 18, 2024
* Author: true
*/
#ifndef USER_PERIPH_ADC_H_
#define USER_PERIPH_ADC_H_
#define LSENS_DARK_THRESHOLD 0x7ff // baseline minimum value reading achieved in darkness
#define LSENS_A_PORT GPIOA
#define LSENS_A_PIN GPIO_Pin_5
#define LSENS_K_PORT GPIOB
#define LSENS_K_PIN GPIO_Pin_0
#define LSENS_ADC_CH ADC_Channel_8
#define LSENS_COARSE_UP 0x990 // counts higher than this increase lsens_coarse, maximum 64
#define LSENS_COARSE_DOWN 0x890 // counts lower than this decrease lsens_coarse, minimum 1
#define LSENS_DARK 48
#define LSENS_BRIGHT 32
enum lsens_mode {
LSENS_READING_IDLE = 0,
LSENS_READING_START,
LSENS_READING_WAIT,
LSENS_READING_TIMEOUT,
LSENS_OUTPUT = 0xff
};
void adc_init();
void adc_convert();
void adc_read();
void adc_set_mode_lsens(uint8_t mode);
uint8_t adc_get_mode_lsens();
void adc_process_lsens();
uint16_t adc_get_lsens();
uint8_t adc_get_lsens_coarse();
#endif /* USER_PERIPH_ADC_H_ */