1 /* 2 * PIC32 peripheral descriptions. 3 * 4 * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __PIC32_H__ 21 #define __PIC32_H__ 22 23 /* Peripheral addresses. 24 * See... 25 * TABLE 4-1: SFR MEMORYMAP 26 * TABLE 11-3: PORTA REGISTER MAP 27 * PIC32MX1XX/2XX 28/36/44-pin Family Data Sheet 28 */ 29 30 #define PMCON 0xBF807000 31 #define PMMODE 0xBF807010 32 #define PMADDR 0xBF807020 33 #define PMDOUT 0xBF807030 34 #define PMDIN 0xBF807040 35 #define PMAEN 0xBF807050 36 #define PMSTAT 0xBF807060 37 38 #define OSCCON 0xBF80F000 39 #define REFOCON 0xBF80F020 40 #define REFOTRIM 0xBF80F030 41 #define CFGCON 0xBF80F200 42 #define SYSKEY 0xBF80F230 43 44 #define U1RXR 0xBF80FA50 45 46 #define RPA0R 0xBF80FB00 47 #define RPA1R 0xBF80FB04 48 #define RPA2R 0xBF80FB08 49 #define RPA3R 0xBF80FB0C 50 #define RPA4R 0xBF80FB10 51 #define RPB0R 0xBF80FB2C 52 #define RPB1R 0xBF80FB30 53 #define RPB2R 0xBF80FB34 54 #define RPB3R 0xBF80FB38 55 #define RPB4R 0xBF80FB3C 56 #define RPB5R 0xBF80FB40 57 #define RPB10R 0xBF80FB54 58 #define RPB15R 0xBF80FB68 59 60 #define INTCON 0xBF881000 61 #define IFS0 0xBF881030 62 #define IFS1 0xBF881040 63 #define IEC0 0xBF881060 64 #define IEC1 0xBF881070 65 #define IPC1 0xBF8810A0 66 #define IPC2 0xBF8810B0 67 #define IPC3 0xBF8810C0 68 #define IPC4 0xBF8810D0 69 #define IPC5 0xBF8810E0 70 #define IPC6 0xBF8810F0 71 #define IPC7 0xBF881100 72 #define IPC8 0xBF881110 73 #define IPC9 0xBF881120 74 #define IPC10 0xBF881130 75 76 #define BMXCON 0xBF882000 77 #define BMXDKPBA 0xBF882010 78 #define BMXDUDBA 0xBF882020 79 #define BMXDUPBA 0xBF882030 80 #define BMXDRMSZ 0xBF882040 81 82 #define ANSELA 0xBF886000 83 #define TRISA 0xBF886010 84 #define PORTA 0xBF886020 85 #define LATA 0xBF886030 86 #define ODCA 0xBF886040 87 #define ANSELB 0xBF886100 88 #define TRISB 0xBF886110 89 #define PORTB 0xBF886120 90 #define LATB 0xBF886130 91 #define ODCB 0xBF886140 92 93 /* DMA conveniences. */ 94 95 #define DMACON 0xBF883000 96 #define DCH0CON 0xBF883060 97 #define DCH1CON 0xBF883120 98 #define DCH2CON 0xBF8831E0 99 #define DCH3CON 0xBF8832A0 100 101 #define DCHMIN 0 102 #define DCHMAX 3 103 #define DCHBASE DCH0CON 104 #define DCHSTEP (DCH1CON - DCH0CON) 105 106 #define DCHxCON 0x00 107 #define DCHxECON 0x10 108 #define DCHxINT 0x20 109 #define DCHxSSA 0x30 110 #define DCHxDSA 0x40 111 #define DCHxSSIZ 0x50 112 #define DCHxDSIZ 0x60 113 #define DCHxSPTR 0x70 114 #define DCHxDPTR 0x80 115 #define DCHxCSIZ 0x90 116 #define DCHxCPTR 0xA0 117 #define DCHxDAT 0xB0 118 119 #define DMAIEC IEC1 120 #define DMAIFS IFS1 121 #define DMAINTBASE 28 122 123 #define DMAIPC IPC10 124 #define DCHIPCBASE 0 125 #define DCHIPCSTEP 8 126 127 /* Output compare conveniences. */ 128 129 #define OC1CON 0xBF803000 130 #define OC2CON 0xBF803200 131 #define OC3CON 0xBF803400 132 #define OC4CON 0xBF803600 133 #define OC5CON 0xBF803800 134 135 #define OCMIN 1 136 #define OCMAX 5 137 #define OCBASE OC1CON 138 #define OCSTEP (OC2CON - OC1CON) 139 140 #define OCxCON 0x00 141 #define OCxR 0x10 142 #define OCxRS 0x20 143 144 #define OCIEC IEC0 145 146 #define OCxIE 1 147 148 #define OCIFS IFS0 149 150 #define OCxIF 1 151 152 #define OCINTBASE 7 153 #define OCINTSTEP 5 154 155 #define OC1IPC IPC1 156 #define OC2IPC IPC2 157 #define OC3IPC IPC3 158 #define OC4IPC IPC4 159 #define OC5IPC IPC5 160 #define OCIPCBASE 16 161 162 /* Timer conveniences. */ 163 164 #define T1CON 0xBF800600 165 #define T2CON 0xBF800800 166 #define T3CON 0xBF800A00 167 #define T4CON 0xBF800C00 168 #define T5CON 0xBF800E00 169 170 #define TIMERMIN 1 171 #define TIMERMAX 5 172 #define TIMERBASE T1CON 173 #define TIMERSTEP (T2CON - T1CON) 174 175 #define TxCON 0x00 176 #define TMRx 0x10 177 #define PRx 0x20 178 179 #define TIMERIEC IEC0 180 181 #define TxIE 1 182 183 #define TIMERIFS IEC0 184 185 #define TxIF 1 186 187 #define TIMERINTBASE 4 188 #define TIMERINTSTEP 5 189 190 #define TIMER1IPC IPC1 191 #define TIMER2IPC IPC2 192 #define TIMER3IPC IPC3 193 #define TIMER4IPC IPC4 194 #define TIMER5IPC IPC5 195 #define TIMERIPCBASE 0 196 197 /* UART conveniences. */ 198 199 #define U1MODE 0xBF806000 200 #define U2MODE 0xBF806200 201 202 #define UARTMIN 1 203 #define UARTMAX 2 204 #define UARTBASE U1MODE 205 #define UARTSTEP (U2MODE - U1MODE) 206 207 #define UxMODE 0x00 208 #define UxSTA 0x10 209 #define UxTXREG 0x20 210 #define UxRXREG 0x30 211 #define UxBRG 0x40 212 213 #define UARTIEC IEC1 214 215 #define UxEIE 1 216 #define UxRIE 2 217 #define UxTIE 4 218 219 #define UARTIFS IFS1 220 221 #define UxEIF 1 222 #define UxRIF 2 223 #define UxTIF 4 224 225 #define UARTINTBASE 7 226 #define UARTINTSTEP 14 227 228 #define UART1IPC IPC8 229 #define UART1IPCBASE 0 230 #define UART2IPC IPC9 231 #define UART2IPCBASE 8 232 233 /* Interrupt numbers. 234 * See... 235 * TABLE 7-1: INTERRUPT IRQ, VECTOR AND BIT LOCATION 236 * PIC32MX1XX/2XX 28/36/44-pin Family Data Sheet 237 */ 238 239 #define DMA0 60 240 #define DMA1 61 241 #define DMA2 62 242 #define DMA3 63 243 #define OC1 7 244 #define OC2 12 245 #define OC3 17 246 #define OC4 22 247 #define OC5 27 248 #define T1 4 249 #define T2 9 250 #define T3 14 251 #define T4 19 252 #define T5 24 253 #define U1RX 40 254 #define U1TX 41 255 #define U2RX 54 256 #define U2TX 55 257 258 /* Address modifiers. 259 * See... 260 * 11.2 CLR, SET and INV Registers 261 * PIC32MX1XX/2XX 28/36/44-pin Family Data Sheet 262 */ 263 264 #define CLR 0x4 265 #define SET 0x8 266 #define INV 0xC 267 268 #endif /* __PIC32_H__ */