From: aleph Date: Wed, 2 Mar 2011 17:29:26 +0000 (+0000) Subject: sam3x-ek: add display backlight control X-Git-Tag: 2.7.0~226 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4c023e11323ac6c6bb47873ada0c24ebb38cd449;p=bertos.git sam3x-ek: add display backlight control git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4740 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/boards/sam3x-ek/hw/hw_lcd.h b/boards/sam3x-ek/hw/hw_lcd.h new file mode 100644 index 00000000..150178f8 --- /dev/null +++ b/boards/sam3x-ek/hw/hw_lcd.h @@ -0,0 +1,73 @@ +/** + * \file + * + * + * \brief Atmel SAM3X-EK LCD backlight control + * + * \author Stefano Fedrigo + */ + +#ifndef HW_LCD_H +#define HW_LCD_H + +#include + +#include +#include +#include + +#define LCD_BACKLIGHT_MAX 32 +#define LCD_BACKLIGHT_PIN BV(27) // Port B + + +INLINE void lcd_setBacklight(uint8_t level) +{ + if (level > LCD_BACKLIGHT_MAX) + level = LCD_BACKLIGHT_MAX; + + PIOB_OER = LCD_BACKLIGHT_PIN; + PIOB_SODR = LCD_BACKLIGHT_PIN; + PIOB_PER = LCD_BACKLIGHT_PIN; + + // Switch off backlight first + PIOB_CODR = LCD_BACKLIGHT_PIN; + timer_delay(1); + + for (unsigned i = 0; i < level; i++) + { + PIOB_CODR = LCD_BACKLIGHT_PIN; + NOP;NOP;NOP;NOP;NOP; + PIOB_SODR = LCD_BACKLIGHT_PIN; + NOP;NOP;NOP;NOP;NOP; + } +} + +#endif /* HW_LCD_H */