From 4c023e11323ac6c6bb47873ada0c24ebb38cd449 Mon Sep 17 00:00:00 2001 From: aleph Date: Wed, 2 Mar 2011 17:29:26 +0000 Subject: [PATCH] sam3x-ek: add display backlight control git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4740 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/sam3x-ek/hw/hw_lcd.h | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 boards/sam3x-ek/hw/hw_lcd.h 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 */ -- 2.25.1