Updated according to new ADC driver API Updated Comments Updated according to new...
authorNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 27 Sep 2016 21:43:06 +0000 (23:43 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Wed, 8 Feb 2023 02:25:21 +0000 (03:25 +0100)
microphone/main.c

index bbb749a..6affd36 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   apps/microphone/main.c
+ *   microphone/main.c
  *
  * ADC example with very high sample rate and auto Tx on serial at high speed.
  *
  *************************************************************************** */
 
 
-#include <stdint.h>
-#include "core/lpc_regs_12xx.h"
-#include "core/lpc_core_cm0.h"
-#include "core/pio.h"
 #include "core/system.h"
 #include "core/systick.h"
+#include "core/pio.h"
 #include "lib/stdio.h"
 #include "drivers/serial.h"
 #include "drivers/gpio.h"
@@ -74,10 +71,6 @@ void system_init()
 {
        /* Stop the watchdog */
        startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
-
-       /* Note: Brown-Out detection must be powered to operate the ADC. adc_on() will power
-        *  it back on if called after system_init() */
-       system_brown_out_detection_config(0);
        system_set_default_power_state();
        clock_config(SELECTED_FREQ);
        set_pins(common_pins);
@@ -97,29 +90,27 @@ void system_init()
  */
 void fault_info(const char* name, uint32_t len)
 {
-       serial_write(0, name, len);
-       /* Wait for end of Tx */
-       serial_flush(0);
-       /* FIXME : Perform soft reset of the micro-controller ! */
+       uprintf(UART0, name);
        while (1);
 }
 
 
 
 /***************************************************************************** */
-int main(void) {
+int main(void)
+{
        system_init();
-       uart_on(0, 1152000, NULL);
-       adc_on();
+       uart_on(UART0, 1152000, NULL);
+       adc_on(NULL);
 
-       adc_start_burst_conversion(LPC_ADC_CHANNEL(0));
+       adc_start_burst_conversion(ADC_MCH(0), LPC_ADC_SEQ(0));
        while (1) {
                /* ADC Test */
                uint16_t val = 0;
                uint8_t tmp = 0;
-               adc_get_value(&val, LPC_ADC_NUM(0));
+               adc_get_value(&val, LPC_ADC(0));
                tmp = (val >> 2);
-               serial_write(0, (char*)&tmp, 1);
+               serial_send_quickbyte(UART0, tmp);
                usleep(20);
        }
        return 0;