#include <stddef.h>
#include <stdint.h>
#include <stm32.h>
-
-#define O_WRITE 0x01
-#define SET 0x02
-#define CLEAR 0x03
+#include <mmap.h>
/* write value (uint8_t) to register */
void regw_u8(volatile uint32_t * reg, uint8_t val, short shift, short flag) {
switch(flag) {
- case O_WRITE:
- (*(volatile uint32_t *) (reg)) = (val << shift);
+ case OWRITE:
+ *reg = (val << shift);
break;
- case SET:
- (*(volatile uint32_t *) (reg)) =
- ((*(volatile uint32_t *) (reg)) | (val << shift));
+ case SETBIT:
+ *reg = *reg | (val << shift);
break;
- case CLEAR:
- (*(volatile uint32_t *) (reg)) = (val << shift);
+ case CLRBIT:
+ *reg = (val << shift);
break;
}
}
void regw_u32(volatile uint32_t * reg, uint32_t val, short shift, short flag) {
switch(flag) {
- case O_WRITE:
- (*(volatile uint32_t *) (reg)) = (val << shift);
+ case OWRITE:
+ //*reg = (val << shift);
+ *reg = (val << shift);
+ break;
+ case SETBIT:
+ *reg = *reg | (val << shift);
break;
- case SET:
- (*(volatile uint32_t *) (reg)) =
- ((*(volatile uint32_t *) (reg)) | (val << shift));
- case CLEAR:
+ case CLRBIT:
//
break;
}