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 scanf or sth this will be obsolete. */
46 char * regtohex(uint32_t addr) {
47 char tmpbuf[6] = {'A', 'B', 'C', 'D', 'E', 'F'};
48 memset(&hexbuf, 0, sizeof(uint32_t) * 8);
51 for (int i = 0; i < 8 ; i++) {
53 tmp = tmp >> (28 - (i * 4));
55 if ((tmp >= 0) && tmp < 10) {
56 hexbuf[i] = (char) tmp + 48;
59 hexbuf[i] = tmpbuf[tmp - 10];
64 int singlehextoreg(char hex) {
67 if (hex >= 'A' && hex <= 'F')
77 uint32_t hextoreg(char * a) {
81 for(int i = 0; i < 8; i++) {
82 tmp = singlehextoreg(*a++);
83 x += tmp << (28 - (i * 4));