TS-8390-47XX Backlight

From embeddedTS Manuals
Revision as of 18:17, 11 September 2013 by Mark (talk | contribs) (Created page with "The backlight brightness can be adjusted by controlling the duty cycle of PWM on the processor DIO. This example takes an integer percentage as the only argument which will s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The backlight brightness can be adjusted by controlling the duty cycle of PWM on the processor DIO. This example takes an integer percentage as the only argument which will set the brightness.

#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>

volatile uint32_t *mvpwmregs = 0;
void set_brightness(int pct) 
{
	if(mvpwmregs == 0) {
		int mem = open("/dev/mem", O_RDWR|O_SYNC);
		assert(mem != -1);
		mvpwmregs = (unsigned int *) mmap(0, 4096,
	  	  PROT_READ | PROT_WRITE, MAP_SHARED, mem, 0xd401a000);
	}

	// duty cycle floor is 57, max is 128
	mvpwmregs[0x004/4] = 57 + ((pct * 71)/100);
}

int main(int argc, char **argv)
{
	set_brightness(atoi(argv[1]));
	return 0;
}