Merge pull request #411 from ADVANSEE/cc2538-adc
cc2538: Add adc driver and example
This commit is contained in:
commit
33abe26ec8
13 changed files with 511 additions and 4 deletions
|
@ -50,6 +50,8 @@
|
|||
* - BTN_DOWN turns on LEDS_REBOOT and causes a watchdog reboot
|
||||
* - BTN_UP to soft reset (SYS_CTRL_PWRDBG::FORCE_WARM_RESET)
|
||||
* - BTN_LEFT and BTN_RIGHT flash the LED defined as LEDS_BUTTON
|
||||
* - ADC sensors : On-chip VDD / 3 and temperature, and ambient light sensor
|
||||
* values are printed over UART periodically.
|
||||
* - UART : Every LOOP_INTERVAL the EM will print something over the
|
||||
* UART. Receiving an entire line of text over UART (ending
|
||||
* in \\r) will cause LEDS_SERIAL_IN to toggle
|
||||
|
@ -68,6 +70,7 @@
|
|||
#include "dev/leds.h"
|
||||
#include "dev/uart.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/adc-sensor.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/sys-ctrl.h"
|
||||
|
@ -111,6 +114,7 @@ rt_callback(struct rtimer *t, void *ptr)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(cc2538_demo_process, ev, data)
|
||||
{
|
||||
int16_t value;
|
||||
|
||||
PROCESS_EXITHANDLER(broadcast_close(&bc))
|
||||
|
||||
|
@ -127,7 +131,18 @@ PROCESS_THREAD(cc2538_demo_process, ev, data)
|
|||
|
||||
if(ev == PROCESS_EVENT_TIMER) {
|
||||
leds_on(LEDS_PERIODIC);
|
||||
printf("Counter = 0x%08x\n", counter);
|
||||
printf("-----------------------------------------\n"
|
||||
"Counter = 0x%08x\n", counter);
|
||||
|
||||
value = adc_sensor.value(ADC_SENSOR_VDD_3);
|
||||
printf("VDD = %d mV\n", value * (3 * 1190) / (2047 << 4));
|
||||
|
||||
value = adc_sensor.value(ADC_SENSOR_TEMP);
|
||||
printf("Temperature = %d mC\n",
|
||||
25000 + ((value >> 4) - 1422) * 10000 / 42);
|
||||
|
||||
value = adc_sensor.value(ADC_SENSOR_ALS);
|
||||
printf("Ambient light sensor = %d raw\n", value);
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue