From: Nathael Pajani Date: Tue, 27 Sep 2016 22:13:31 +0000 (+0200) Subject: Exanh test app changed according to ADC and timers API changes. Includes changes... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=8776c6aae67576cd98520e09d13f0964632726ef;p=soft%2Flpc82x%2Fexanh Exanh test app changed according to ADC and timers API changes. Includes changes according to latest test. --- diff --git a/test/main.c b/test/main.c index 9e496cc..accd5d2 100644 --- a/test/main.c +++ b/test/main.c @@ -57,20 +57,18 @@ const struct pio_config common_pins[] = { /* ADC */ { LPC_ADC_AD2_PIO_0_14, LPC_FIXED, 0 }, /* Debug */ { LPC_ADC_AD9_PIO_0_17, LPC_FIXED, 0 }, - { LPC_ADC_AD10_PIO_0_13, LPC_FIXED, 0 }, /* Timers */ - { LPC_GPIO_0_8, LPC_SCT_POUT0, 0 }, - { LPC_GPIO_0_9, LPC_SCT_POUT1, 0 }, - { LPC_GPIO_0_3, LPC_SCT_POUT2, 0 }, /* Debug */ + { LPC_GPIO_0_9, LPC_SCT_POUT0, 0 }, + { LPC_GPIO_0_3, LPC_SCT_POUT1, 0 }, /* Debug */ /* GPIO */ - { LPC_GPIO_0_2, LPC_GPIO, 0 }, + { LPC_GPIO_0_2, LPC_GPIO, 0 }, /* Led */ { LPC_GPIO_0_12, LPC_GPIO, 0 }, ARRAY_LAST_PIO, }; /* Configure pins as used for capacitance sensing */ const struct pio_config capacitance_pins[] = { - { LPC_GPIO_0_9, LPC_SCT_POUT1, 0 }, + { LPC_GPIO_0_9, LPC_SCT_POUT0, 0 }, { LPC_ADC_AD9_PIO_0_17, LPC_FIXED, 0 }, ARRAY_LAST_PIO, }; @@ -99,7 +97,7 @@ void temp_config(int uart_num) /* Temp sensor */ ret = tmp101_sensor_config(&tmp101_sensor); if (ret != 0) { - serial_write(uart_num, "Temp config error\r\n", 19); + uprintf(uart_num, "Temp config error\n"); } } @@ -113,9 +111,9 @@ void temp_display(int uart_num) msleep(50); /* Wait for the end of the conversion : 40ms */ len = tmp101_sensor_read(&tmp101_sensor, &raw, &deci_degrees); if (len != 0) { - serial_write(uart_num, "Temp read error\r\n", 19); + uprintf(uart_num, "Temp read error\n"); } else { - uprintf(uart_num, "Temp read: %d,%d - raw: 0x%04x.\r\n", + uprintf(uart_num, "Temp read: %d,%d - raw: 0x%04x.\n", (deci_degrees/10), (deci_degrees%10), raw); } } @@ -153,19 +151,15 @@ void fault_info(const char* name, uint32_t len) void set_led_color(void) { uint16_t red = 0, green = 0, blue = 0; - static uint16_t tmp = 0; /* Get ADC values */ - adc_get_value(&tmp, LPC_ADC_NUM(9)); - red = tmp; - adc_get_value(&tmp, LPC_ADC_NUM(10)); - blue = tmp; + adc_get_value(&blue, LPC_ADC(9)); /* Set pixel */ - ws2812_set_pixel(0, (((red >> 6) & 0xFF) - 30), green, (((blue >> 6) & 0xFF) - 30)); + ws2812_set_pixel(0, red, green, (((blue >> 6) & 0xFF) - 30)); ws2812_send_frame(0); - uprintf(UART0, "ADC9: %d, ADC10: %d\n", red, blue); + uprintf(UART0, "ADC9: %d\n", blue); } @@ -176,11 +170,11 @@ void trigger_message(uint32_t int_num) { } const struct lpc_timer_pwm_config pwm_conf = { - .nb_channels = 2, + .nb_channels = 1, .period = 30, - .outputs_initial_state = 0x07, - .match_values = { 15, 10, 15, }, - .outputs = { 0, 1, 2, }, + .outputs_initial_state = 0x01, + .match_values = { 10, }, + .outputs = { 0, }, }; /***************************************************************************** */ @@ -199,8 +193,7 @@ int main(void) config_gpio(&cap_trig_gpio, 0, GPIO_DIR_OUT, 0); config_gpio(&cap_adc_gpio, 0, GPIO_DIR_OUT, 0); adc_on(NULL); - adc_start_burst_conversion(LPC_ADC_CHANNEL(2) | LPC_ADC_CHANNEL(9) | LPC_ADC_CHANNEL(10), LPC_ADC_SEQA); -// adc_start_burst_conversion(LPC_ADC_CHANNEL(9) | LPC_ADC_CHANNEL(10), LPC_ADC_SEQA); + adc_start_burst_conversion(ADC_MCH(9), LPC_ADC_SEQA); uprintf(UART0, "ADC config done\n"); /* Led strip configuration */