bertos/gfx/text.c \
bertos/cpu/cortex-m3/drv/timer_cm3.c \
bertos/drv/timer.c \
+ bertos/drv/adc.c \
+ bertos/cpu/cortex-m3/drv/adc_sam3.c \
bertos/mware/formatwr.c \
bertos/mware/sprintf.c \
bertos/gfx/line.c \
# CPU specific flags and options, defined in the CPU definition files.
# Automatically generated by the wizard. PLEASE DO NOT EDIT!
-display_CPU_CPPASRC = bertos/cpu/cortex-m3/hw/crt_cm3.S bertos/cpu/cortex-m3/hw/vectors_cm3.S
+display_CPU_CPPASRC = bertos/cpu/cortex-m3/hw/crt_cm3.S bertos/cpu/cortex-m3/hw/vectors_cm3.S
display_CPU_CPPAFLAGS = -g -gdwarf-2 -mthumb -mno-thumb-interwork
display_CPU_CPPFLAGS = -O0 -g3 -gdwarf-2 -mthumb -mno-thumb-interwork -fno-strict-aliasing -fwrapv -fverbose-asm -Ibertos/cpu/cortex-m3/ -D__ARM_SAM3X8__
-display_CPU_CSRC = bertos/cpu/cortex-m3/hw/init_cm3.c bertos/cpu/cortex-m3/drv/irq_cm3.c bertos/cpu/cortex-m3/drv/clock_sam3.c
+display_CPU_CSRC = bertos/cpu/cortex-m3/hw/init_cm3.c bertos/cpu/cortex-m3/drv/irq_cm3.c bertos/cpu/cortex-m3/drv/clock_sam3.c
display_PROGRAMMER_CPU = sam3
display_CPU_LDFLAGS = -mthumb -mno-thumb-interwork -nostartfiles -Wl,--no-warn-mismatch -Wl,-dT bertos/cpu/cortex-m3/scripts/sam3x8_rom.ld
display_STOPFLASH_SCRIPT = bertos/prg_scripts/arm/stopopenocd.sh
#include "hw/hw_led.h"
#include "hw/hw_lcd.h"
+#include "hw/hw_adc.h"
#include "hw/hw_sdram.h"
#include <cfg/debug.h>
+
#include <cpu/irq.h>
+
#include <struct/heap.h>
+
#include <drv/timer.h>
#include <drv/kbd.h>
#include <drv/lcd_hx8347.h>
+#include <drv/adc.h>
+
#include <gfx/gfx.h>
#include <gfx/font.h>
#include <gfx/text.h>
#include <gui/menu.h>
#include <icons/logo.h>
+
#include <io/kfile.h>
+
#include <kern/signal.h>
#include <kern/proc.h>
UNREACHABLE();
}
+static void read_adc(Bitmap *bm)
+{
+ gfx_bitmapClear(bm);
+ text_xprintf(bm, 0, 0, TEXT_FILL | TEXT_CENTER, "ADC Value");
+ while (1)
+ {
+ uint16_t value = ADC_RANGECONV(adc_read(1), 0, 3300);
+ uint16_t temp = hw_convertToDegree (adc_read(ADC_TEMPERATURE_CH));
+
+ text_xprintf(lcd_bitmap, 2, 0, TEXT_FILL | TEXT_CENTER,
+ "Volage on VR1: %d.%dV", value / 1000, value % 1000);
+ text_xprintf(lcd_bitmap, 3, 0, TEXT_FILL | TEXT_CENTER,
+ "CPU temperature: %d.%dC", temp / 10, temp % 10);
+ lcd_hx8347_blitBitmap(bm);
+ timer_delay(400);
+ if (kbd_peek() & KEY_MASK)
+ break;
+ }
+}
+
static struct MenuItem main_items[] =
{
{ (const_iptr_t)"Show uptime", 0, (MenuHook)uptime, NULL },
{ (const_iptr_t)"Display brightness", 0, (MenuHook)setBrightness, NULL },
{ (const_iptr_t)"Reboot", 0, (MenuHook)soft_reset, NULL },
+ { (const_iptr_t)"Read ADC value", 0, (MenuHook)read_adc, NULL },
{ (const_iptr_t)0, 0, NULL, (iptr_t)0 }
};
static struct Menu main_menu = { main_items, "BeRTOS", MF_STICKY | MF_SAVESEL, NULL, 0, lcd_hx8347_blitBitmap };
unsigned i;
IRQ_ENABLE;
-
kdbg_init();
LED_INIT();
timer_init();
proc_init();
sdram_init();
+ adc_init();
+
+ /* Enable the adc to read internal temperature sensor */
+ hw_enableTempRead();
heap_init(&heap, (void *)SDRAM_BASE, SDRAM_SIZE);
lcd_bitmap = heap_allocmem(&heap, RAST_SIZE(LCD_WIDTH, LCD_HEIGHT));
menu_handle(&main_menu);
cpu_relax();
}
+
}