Files
aqhomecontrol/avr/modules/lcd2/ili9341/backlight.asm
2026-01-27 20:31:00 +01:00

58 lines
1.2 KiB
NASM

; ***************************************************************************
; copyright : (C) 2026 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome". *
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
#ifndef AQH_AVR_ILI9341_BACKLIGHT_ASM
#define AQH_AVR_ILI9341_BACKLIGHT_ASM
; doesn't work with my displays (seems to be binary: either on or off)
;
; Uses timer 1, set to Fast PWM mode, prescaler 8
;
Display_BacklightInit:
sbi ILI9341_BACKLIGHT_DDR, ILI9341_BACKLIGHT_PIN
ldi r16, (1<<COM1A1) | (0<<COM1A0) | (0<<WGM11) | (1<<WGM10) ; Fast PWM mode, clear pin on match
outr TCCR1A, r16
; Prescaler 8, 8-Bit Fast PWM mode
ldi r16, (0<<WGM13) | (1<<WGM12) | (0<<CS12) | (1<<CS11) | (0<<CS10);
; set to 50 %
ldi r16, 0xff
clr r17
outr OCR1AH, r17
outr OCR1AL, r16
; mode 5: Fast PWM, TOP=OCR1A
; WGM13: 0
; WGM12: 1
; WGM11: 0
; WGM10: 1
; @param r16 value to set (0-255)
Display_SetBacklight:
clr r17
outr OCR1AH, r17
outr OCR1AL, r16
ret
; @end
#endif