Comply the demo project to new spi dma interface.
[bertos.git] / boards / sam3n-ek / templates / empty / main.c
index 0fc2146e082d73cc5dd27f052f67800b371bb894..8e5fb7826052bda9b9cf54a2dd415de3f11d6c48 100644 (file)
 #include "hw/hw_led.h"
 #include "hw/hw_lcd.h"
 
+#include <cfg/debug.h>
+
 #include <cpu/irq.h>
-#include <cpu/arm/drv/spi_dma_at91.h>
+#include <drv/spi_dma.h>
 
 #include <drv/timer.h>
 #include <drv/kbd.h>
 #include <drv/lcd_ili9225.h>
 
 
-struct SpiDmaAt91 spi;
-static uint8_t raster[RAST_SIZE(LCD_WIDTH, LCD_HEIGHT)];
+/* Bitmap to display on the OLED display */
 static Bitmap lcd_bitmap;
-static int lcd_brightness = LCD_BACKLIGHT_MAX;
+/* Raster associated to the Bitmap image */
+static uint8_t raster[RAST_SIZE(LCD_WIDTH, LCD_HEIGHT)];
+/* LCD spi context with DMA access */
+struct SpiDma spi;
 
 static void init(void)
 {
     /* Enable all the interrupts */
     IRQ_ENABLE;
 
-    /* Initialize debugging module (allow kprintf(), etc.) */
-    kdbg_init();
-    /* Initialize system timer */
-    timer_init();
-    /* Initialize LED driver */
-    LED_INIT();
+       /* Initialize debugging module (allow kprintf(), etc.) */
+       kdbg_init();
+       /* Initialize system timer */
+       timer_init();
+       /* Initialize LED driver */
+       LED_INIT();
        /* Init spi on dma to drive lcd */
        spi_dma_init(&spi);
        spi_dma_setclock(LCD_SPICLOCK);
@@ -72,17 +76,18 @@ static void init(void)
        lcd_ili9225_init(&spi.fd);
        /* Init the backligth display leds */
        LCD_BACKLIGHT_INIT();
-       lcd_setBacklight(lcd_brightness);
-    /* Draw an empty Bitmap on the screen */
-    gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
-    /* Refresh the display */
+       lcd_setBacklight(LCD_BACKLIGHT_MAX);
+       /* Draw an empty Bitmap on the screen */
+       gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
+       /* Refresh the display */
        lcd_ili9225_blitBitmap(&lcd_bitmap);
-    /* Initialize the keypad driver */
-    kbd_init();
+       /* Initialize the keypad driver */
+       kbd_init();
 }
 
 int main(void)
 {
+       /* Hardware initialization */
        init();