/****************************************************************************
- * apps/ultrasonic_sensor/main.c
+ * apps/base/ultrasonic_sensor/main.c
*
* Ultrasonic range measurement example
*
* Refer to readme file for further information.
*/
-#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"
{
/* 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_brown_out_detection_config(0); /* No ADC used */
system_set_default_power_state();
clock_config(SELECTED_FREQ);
set_pins(common_pins);
*/
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);
}
#define DELAY 50
/***************************************************************************** */
-int main(void) {
+int main(void)
+{
uint32_t next_time = 0;
uint32_t delay = 0;
system_init();
- uart_on(0, 115200, NULL);
+ uart_on(UART0, 115200, NULL);
next_time = systick_get_tick_count();
/* Callback on pulse start and end */
set_gpio_callback(pulse_feedback, &sensor, EDGES_BOTH);
- uprintf(0, "Ultrasonic distance sensor using GPIO %d.%d\n", sensor.port, sensor.pin);
+ uprintf(UART0, "Ultrasonic distance sensor using GPIO %d.%d\n", sensor.port, sensor.pin);
while (1) {
uint32_t distance = 0;
distance = ((pulse_duration * 10) / (get_main_clock() / (1000*1000)));
distance = distance / 29;
/* Send value on serial */
- uprintf(0, "dist: %dmm\n", distance);
+ uprintf(UART0, "dist: %dmm\n", distance);
/* And wait at least 50ms between loops */
delay = next_time - systick_get_tick_count();