Commit 7e02eb84 authored by Lisa Marie Dreier's avatar Lisa Marie Dreier
Browse files

adc liest aus

parent aa4d60cd
......@@ -21,6 +21,14 @@ void adc_init();
#endif
*/
#ifdef __cplusplus
extern "C" {
#endif
void clock_setup(void);
void adc_setup(void);
uint16_t read_adc_naiive(uint8_t channel);
#ifdef __cplusplus
}
#endif
......@@ -26,8 +26,8 @@ extern uint32_t SystemCoreClock;
void test_init() {
adc_setup();
clock_setup();
adc_setup();
ezs_printf("\n================================\n\n");
......@@ -124,6 +124,10 @@ void test_thread(cyg_addrword_t arg) {
ezs_printf("Button state: %d\n", button_get());
servo_set(SERVO_0, button_get()*255);
cyg_thread_delay(250);
uint16_t input_adc = read_adc_naiive(11);
ezs_printf("adc: %d\n", input_adc);
}
for (i = 255; i > 0; i -= 5) {
......@@ -132,6 +136,9 @@ void test_thread(cyg_addrword_t arg) {
ezs_printf("Button state: %d\n", button_get());
servo_set(SERVO_0, button_get()*255);
cyg_thread_delay(250);
uint16_t input_adc = read_adc_naiive(11);
ezs_printf("adc: %d\n", input_adc);
}
}
}
......
......@@ -12,25 +12,27 @@
//#define GPIO_C1 CYGHWR_HAL_STM32_PIN_OUT(C, 1, PUSHPULL, NONE, LOW)
void clock_setup()
extern "C" void clock_setup()
{
rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]);
/* Enable GPIOD clock for LED & USARTs. */
rcc_periph_clock_enable(RCC_GPIOD);
rcc_periph_clock_enable(RCC_GPIOA);
//rcc_periph_clock_enable(RCC_GPIOD);
//rcc_periph_clock_enable(RCC_GPIOA);
/* Enable clocks for USART2 and dac */
rcc_periph_clock_enable(RCC_USART2);
rcc_periph_clock_enable(RCC_DAC);
//rcc_periph_clock_enable(RCC_USART2);
//rcc_periph_clock_enable(RCC_DAC);
/* And ADC*/
rcc_periph_clock_enable(RCC_ADC1);
}
void adc_setup()
extern "C" void adc_setup()
{
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
//gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
adc_power_off(ADC1);
adc_disable_scan_mode(ADC1);
......@@ -40,7 +42,7 @@ void adc_setup()
}
uint16_t read_adc_naiive(uint8_t channel)
extern "C" uint16_t read_adc_naiive(uint8_t channel)
{
uint8_t channel_array[16];
channel_array[0] = channel;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment