forked from sodnpoo/fernly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd-bl.c
40 lines (32 loc) · 793 Bytes
/
cmd-bl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string.h>
#include "bionic.h"
#include "memio.h"
#include "printf.h"
#include "serial.h"
#include "fernvale-bl.h"
int cmd_bl(int argc, char **argv)
{
uint32_t level;
int i;
if (argc < 1) {
printf("Usage: bl [level 0-%d]\n", BLLED_MAX_LEVEL);
return -1;
}
level = strtoul(argv[0], NULL, 0);
if( level > BLLED_MAX_LEVEL ) {
level = 0;
printf( "Backlight level should be 0-5\n" );
}
if( level > 0 ) {
for( i = 0; i < BLLED_BANKS; i++ ) {
*((volatile uint32_t *) BLLED_REG0_BANK(i)) =
((level << BLLED_REG0_STEP_BIT) & BLLED_REG0_STEP_MSK) |
((1 << BLLED_REG0_MODE_BIT) | (1 << BLLED_REG0_EN_BIT));
}
} else {
for( i = 0; i < BLLED_BANKS; i++ ) {
*((volatile uint32_t *) BLLED_REG0_BANK(i)) = 0; // meh
}
}
return 0;
}