/****************************************************************************
- * apps/adc/main.c
+ * apps/base/adc/main.c
*
* ADC example
*
*************************************************************************** */
-#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 "lib/stdio.h"
+#include "core/pio.h"
+#include "drivers/adc.h"
#include "drivers/serial.h"
-#include "drivers/gpio.h"
#include "extdrv/status_led.h"
-#include "drivers/adc.h"
+#include "lib/stdio.h"
#define MODULE_VERSION 0x04
/***************************************************************************** */
/* This will display the integer value read on the ADC, between 0 and 1024.
- * ADC must be initialised prior to calls to adc_display() (it means that adc_on()
+ * ADC must be initialised prior to calls to adc_display() (it means that adc_on(NULL)
* must be called before using this function.
* adc_num is an ADC channel number (integer between 0 and 7)
- * use LPC_ADC_NUM(x) for channel selection.
+ * use LPC_ADC(x) for channel selection.
* returns ADC convertion value or negative value on error.
*/
int adc_display(int adc_num, int uart_num)
uint16_t val = 0;
int ret = 0;
- adc_start_convertion_once(adc_num, 0);
+ adc_start_convertion_once(adc_num, LPC_ADC_SEQ(0), 0);
msleep(10);
ret = adc_get_value(&val, adc_num);
if (ret < 0) {
/* Display the temperature computed from adc convertion of the voltage output of
* a TMP36 analog temperature sensor
- * ADC must be initialised prior to calls to TMP36_display() (it means that adc_on()
+ * ADC must be initialised prior to calls to TMP36_display() (it means that adc_on(NULL)
* must be called before using this function.
* adc_num is an ADC channel number (integer between 0 and 7)
- * use LPC_ADC_NUM(x) for channel selection.
+ * use LPC_ADC(x) for channel selection.
*/
void TMP36_display(int adc_num, int uart_num)
{
uint16_t val = 0;
int ret = 0;
- adc_start_convertion_once(adc_num, 0);
+ adc_start_convertion_once(adc_num, LPC_ADC_SEQ(0), 0);
msleep(8);
ret = adc_get_value(&val, adc_num);
if (ret == 0) {
{
/* 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);
set_pins(adc_pins);
- gpio_on();
status_led_config(&status_led_green, &status_led_red);
/* System tick timer MUST be configured and running in order to use the sleeping
* functions */
* will be used when it's not overridden here.
* Note : The default one does a simple infinite loop. If the watchdog is deactivated
* the system will hang.
+ * An alternative would be to perform soft reset of the micro-controller.
*/
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, 115200, NULL);
- adc_on();
+ uart_on(UART0, 115200, NULL);
+ adc_on(NULL);
while (1) {
chenillard(500);
/* ADC Test */
- adc_display(LPC_ADC_NUM(0), 0);
- TMP36_display(LPC_ADC_NUM(1), 0);
+ adc_display(LPC_ADC(0), 0);
+ TMP36_display(LPC_ADC(1), 0);
}
return 0;
}