paul@0 | 1 | #ifndef __ASSEMBLER__ |
paul@0 | 2 | |
paul@0 | 3 | #ifndef __PIC32_C_H__ |
paul@0 | 4 | #define __PIC32_C_H__ |
paul@0 | 5 | |
paul@0 | 6 | #include <stdint.h> |
paul@2 | 7 | #include "mips.h" |
paul@0 | 8 | #include "pic32.h" |
paul@0 | 9 | |
paul@0 | 10 | /* Access. */ |
paul@0 | 11 | |
paul@0 | 12 | #define REG(mem) *((volatile uint32_t *) (mem)) |
paul@0 | 13 | |
paul@0 | 14 | /* Bit clearing, setting and inverting. */ |
paul@0 | 15 | |
paul@0 | 16 | #define CLR_REG(mem, val) (REG(mem + CLR) = val) |
paul@0 | 17 | #define SET_REG(mem, val) (REG(mem + SET) = val) |
paul@0 | 18 | #define INV_REG(mem, val) (REG(mem + INV) = val) |
paul@0 | 19 | |
paul@2 | 20 | /* Address translation. */ |
paul@2 | 21 | |
paul@2 | 22 | #define PHYSICAL(addr) (((uint32_t) addr) - KSEG0_BASE) |
paul@2 | 23 | #define HW_PHYSICAL(addr) (((uint32_t) addr) - KSEG1_BASE) |
paul@2 | 24 | |
paul@3 | 25 | /* Register collection access. */ |
paul@3 | 26 | |
paul@3 | 27 | #define DMA_REG(channel, reg) (DCHBASE + reg + (channel - DCHMIN) * DCHSTEP) |
paul@7 | 28 | #define TIMER_REG(channel, reg) (TIMERBASE + reg + (channel - TIMERMIN) * TIMERSTEP) |
paul@3 | 29 | #define UART_REG(channel, reg) (UARTBASE + reg + (channel - UARTMIN) * UARTSTEP) |
paul@3 | 30 | |
paul@0 | 31 | #endif /* __PIC32_C_H__ */ |
paul@0 | 32 | |
paul@0 | 33 | #endif /* __ASSEMBLER__ */ |