From 35b2de49e2b372c66e61457c3ec007c777e2393b Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 5 Nov 2010 10:50:26 +0000 Subject: [PATCH] Add headerguard, use nops to wait. Define setbacklite function to change the ligth level. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4507 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/sam3n-ek/hw/hw_lcd.h | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/boards/sam3n-ek/hw/hw_lcd.h b/boards/sam3n-ek/hw/hw_lcd.h index 8aaacee9..89b4fa2a 100644 --- a/boards/sam3n-ek/hw/hw_lcd.h +++ b/boards/sam3n-ek/hw/hw_lcd.h @@ -33,27 +33,46 @@ * \brief Atmel SAM3N-EK testcase * * \author Luca Ottaviano + * \author Daniele Basile */ +#ifndef HW_LCD_H +#define HW_LCD_H + +#include + +#include +#include + #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 */ -- 2.25.1