5 #include <lib/regfunc.h>
6 #include <lib/string.h>
11 /* write value (uint8_t) to register */
12 void regw_u8(volatile uint32_t * reg, uint8_t val, short shift, short flag) {
16 *reg = (val << shift);
19 *reg = *reg | (val << shift);
22 *reg = (val << shift);
27 /* write value (uint32_t) to register */
28 void regw_u32(volatile uint32_t * reg, uint32_t val, short shift, short flag) {
32 *reg = (val << shift);
35 *reg = *reg | (val << shift);
42 /* Print out the hexidecimal representation of an integer
43 After implementation of a printf function, this code
47 char * regtohex(uint32_t addr) {
48 char tmpbuf[6] = {'A', 'B', 'C', 'D', 'E', 'F'};
49 memset(&hexbuf, 0, sizeof(uint32_t) * 8);
52 for (int i = 0; i < 8 ; i++) {
54 tmp = tmp >> (28 - (i * 4));
56 if ((tmp >= 0) && tmp < 10) {
57 hexbuf[i] = (char) tmp + 48;
60 hexbuf[i] = tmpbuf[tmp - 10];