Add headerguard, use nops to wait. Define setbacklite function to change the ligth...
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 5 Nov 2010 10:50:26 +0000 (10:50 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 5 Nov 2010 10:50:26 +0000 (10:50 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4507 38d2e660-2303-0410-9eaa-f027e97ec537

boards/sam3n-ek/hw/hw_lcd.h

index 8aaacee9e07ec4378c4ed0924ba91c98917b8c45..89b4fa2ad5e920e0c4f8e44bf073da4d065e5e15 100644 (file)
  * \brief Atmel SAM3N-EK testcase
  *
  * \author Luca Ottaviano <lottaviano@develer.com>
+ * \author Daniele Basile <asterix@develer.com>
  */
 
+#ifndef HW_LCD_H
+#define HW_LCD_H
+
+#include <io/cm3.h>
+
+#include <cpu/attr.h>
+#include <cpu/types.h>
+
 #define LCD_BACKLIGHT_MAX  15
 #define LCD_BACKLIGHT_PIN  BV(13)    // Port C
 #define LCD_SPICLOCK       12000000  // Minimum cycle len = 80 ns according specs
 
-#define LCD_BACKLIGHT_INIT() \
-       do { \
-               PIOC_OER = LCD_BACKLIGHT_PIN; \
-               PIOC_SODR = LCD_BACKLIGHT_PIN; \
-               PIOC_PER = LCD_BACKLIGHT_PIN; \
-       } while(0)
 
 #define LCD_BACKLIGHT_LEVEL_UP() \
        do \
        { \
                PIOC_CODR = LCD_BACKLIGHT_PIN; \
-               PIOC_CODR = LCD_BACKLIGHT_PIN; \
-               PIOC_CODR = LCD_BACKLIGHT_PIN; \
-               PIOC_SODR = LCD_BACKLIGHT_PIN; \
+               NOP;NOP;NOP;NOP;NOP; \
                PIOC_SODR = LCD_BACKLIGHT_PIN; \
+               NOP;NOP;NOP;NOP;NOP; \
+       } while(0)
+
+
+INLINE void lcd_setBacklight(uint8_t level)
+{
+       if (level > LCD_BACKLIGHT_MAX)
+               level = LCD_BACKLIGHT_MAX;
+
+       for (uint8_t i = level; i <= LCD_BACKLIGHT_MAX; i++)
+               LCD_BACKLIGHT_LEVEL_UP();
+}
+
+#define LCD_BACKLIGHT_INIT() \
+       do { \
+               PIOC_OER = LCD_BACKLIGHT_PIN; \
                PIOC_SODR = LCD_BACKLIGHT_PIN; \
+               PIOC_PER = LCD_BACKLIGHT_PIN; \
        } while(0)
 
+#endif /* HW_LCD_H */