OpenCores
URL https://opencores.org/ocsvn/neo430/neo430/trunk

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [sw/] [lib/] [neo430/] [include/] [neo430.h] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
// #################################################################################################
2
// #  < neo430.h - MAIN NEO430 INCLUDE FILE >                                                      #
3
// # ********************************************************************************************* #
4
// # BSD 3-Clause License                                                                          #
5
// #                                                                                               #
6
// # Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
7
// #                                                                                               #
8
// # Redistribution and use in source and binary forms, with or without modification, are          #
9
// # permitted provided that the following conditions are met:                                     #
10
// #                                                                                               #
11
// # 1. Redistributions of source code must retain the above copyright notice, this list of        #
12
// #    conditions and the following disclaimer.                                                   #
13
// #                                                                                               #
14
// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
15
// #    conditions and the following disclaimer in the documentation and/or other materials        #
16
// #    provided with the distribution.                                                            #
17
// #                                                                                               #
18
// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
19
// #    endorse or promote products derived from this software without specific prior written      #
20
// #    permission.                                                                                #
21
// #                                                                                               #
22
// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
23
// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
24
// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
25
// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
26
// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
27
// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
28
// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
29
// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
30
// # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
31
// # ********************************************************************************************* #
32
// # The NEO430 Processor - https://github.com/stnolting/neo430                                    #
33
// #################################################################################################
34
 
35
#ifndef neo430_h
36
#define neo430_h
37
 
38
// Standard libraries
39
#include <stdint.h>
40
#include <stdlib.h>
41
 
42
// ----------------------------------------------------------------------------
43
// Aux data types
44
// ----------------------------------------------------------------------------
45
union uint16_u { uint16_t uint16; uint8_t  uint8[ sizeof(uint16_t)/1]; };
46
union uint32_u { uint32_t uint32; uint16_t uint16[sizeof(uint32_t)/2]; uint8_t  uint8[ sizeof(uint32_t)/1]; };
47
union uint64_u { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/4];  uint16_t uint16[sizeof(uint64_t)/2]; uint8_t uint8[sizeof(uint32_t)/1]; };
48
 
49
union  int16_u { int16_t  int16; int8_t   int8[ sizeof(int16_t)/1]; };
50
union  int32_u { int32_t  int32; int16_t  int16[sizeof(int32_t)/2]; int8_t  int8[ sizeof(int32_t)/1]; };
51
union  int64_u { int64_t  int64; int32_t  int32[sizeof(int64_t)/4]; int16_t int16[sizeof(int64_t)/2]; int8_t int8[sizeof(int32_t)/1]; };
52
 
53
 
54
// ----------------------------------------------------------------------------
55
// CPU Status Register (r2) Flags
56
// ----------------------------------------------------------------------------
57
#define C_FLAG 0  // r/w: carry
58
#define Z_FLAG 1  // r/w: zero
59
#define N_FLAG 2  // r/w: negative
60
#define I_FLAG 3  // r/w: global interrupt enable
61
#define S_FLAG 4  // r/w: sleep
62
#define P_FLAG 5  // r/w: parity (if enabled for synthesis)
63
#define V_FLAG 8  // r/w: overflow
64
#define Q_FLAG 14 // -/w: clear pending IRQ buffer when set
65
#define R_FLAG 15 // r/w: allow write-access to IMEM
66
 
67
 
68
// ----------------------------------------------------------------------------
69
// Processor peripheral/IO devices
70
// Beginning of IO area: 0xFF80
71
// Size of IO area: 128 bytes
72
// ----------------------------------------------------------------------------
73
#define REG8  (volatile uint8_t*)        // memory-mapped register
74
#define REG16 (volatile uint16_t*)       // memory-mapped register
75
#define REG32 (volatile uint32_t*)       // memory-mapped register
76
#define ROM8  (const volatile uint8_t*)  // memory-mapped read-only constant
77
#define ROM16 (const volatile uint16_t*) // memory-mapped read-only constant
78
#define ROM32 (const volatile uint32_t*) // memory-mapped read-only constant
79
 
80
 
81
// ----------------------------------------------------------------------------
82
// Start of memory sections
83
// ----------------------------------------------------------------------------
84
#define IMEM_ADDR_BASE 0x0000 // r/(w)/x: instruction memory
85
#define DMEM_ADDR_BASE 0xC000 // r/w/x:   data memory
86
#define BTLD_ADDR_BASE 0xF000 // r/-/x:   bootloader memory
87
 
88
 
89
// ----------------------------------------------------------------------------
90
// Interrupt vectors, located at the beginning of DMEM
91
// ----------------------------------------------------------------------------
92
#define IRQVEC_TIMER  (*(REG16 (DMEM_ADDR_BASE + 0))) // r/w: timer match
93
#define IRQVEC_SERIAL (*(REG16 (DMEM_ADDR_BASE + 2))) // r/w: uart/spi/twi irqs
94
#define IRQVEC_GPIO   (*(REG16 (DMEM_ADDR_BASE + 4))) // r/w: gpio pin change
95
#define IRQVEC_EXT    (*(REG16 (DMEM_ADDR_BASE + 6))) // r/w: external IRQ
96
 
97
 
98
// ----------------------------------------------------------------------------
99
// Unsigned Multiplier/Divider Unit (MULDIV)
100
// ----------------------------------------------------------------------------
101
#define MULDIV_OPA_RESX      (*(REG16 0xFF80)) // r/w: operand A (dividend or factor1) / resx: quotient or product low word
102
#define MULDIV_OPB_UMUL_RESY (*(REG16 0xFF82)) // r/w: operand B (factor2) for unsigned multiplication / resy: remainder or product high word
103
#define MULDIV_OPB_SMUL      (*(REG16 0xFF84)) // -/w: operand B (factor2) for signed multiplication
104
#define MULDIV_OPB_UDIV      (*(REG16 0xFF86)) // -/w: operand B (divisor) for unsigned division
105
#define MULDIV_R32bit        (*(ROM32 (&MULDIV_OPA_RESX))) // r/-: read result as 32-bit data word
106
 
107
 
108
// ----------------------------------------------------------------------------
109
// Frequency Generator (FREQ_GEN)
110
// ----------------------------------------------------------------------------
111
#define FREQ_GEN_CT     (*(REG16 0xFF88)) // r/w: control register
112
#define FREQ_GEN_TW_CH0 (*(REG16 0xFF8A)) // -/w: tuning word channel 0
113
#define FREQ_GEN_TW_CH1 (*(REG16 0xFF8C)) // -/w: tuning word channel 1
114
#define FREQ_GEN_TW_CH2 (*(REG16 0xFF8E)) // -/w: tuning word channel 2
115
 
116
// FREQ_GEN control register
117
#define FREQ_GEN_CT_CH0_EN     0 // r/w: enable NCO channel 0
118
#define FREQ_GEN_CT_CH1_EN     1 // r/w: enable NCO channel 1
119
#define FREQ_GEN_CT_CH2_EN     2 // r/w: enable NCO channel 2
120
#define FREQ_GEN_CT_CH0_PRSC0  3 // r/w: prescaler select bit 0 for channel 0
121
#define FREQ_GEN_CT_CH0_PRSC1  4 // r/w: prescaler select bit 1 for channel 0
122
#define FREQ_GEN_CT_CH0_PRSC2  5 // r/w: prescaler select bit 2 for channel 0
123
#define FREQ_GEN_CT_CH1_PRSC0  6 // r/w: prescaler select bit 0 for channel 1
124
#define FREQ_GEN_CT_CH1_PRSC1  7 // r/w: prescaler select bit 1 for channel 1
125
#define FREQ_GEN_CT_CH1_PRSC2  8 // r/w: prescaler select bit 2 for channel 1
126
#define FREQ_GEN_CT_CH2_PRSC0  9 // r/w: prescaler select bit 0 for channel 2
127
#define FREQ_GEN_CT_CH2_PRSC1 10 // r/w: prescaler select bit 1 for channel 2
128
#define FREQ_GEN_CT_CH2_PRSC2 11 // r/w: prescaler select bit 2 for channel 2
129
 
130
// clock prescalers 
131
#define FREQ_GEN_PRSC_2    0 // CLK/2
132
#define FREQ_GEN_PRSC_4    1 // CLK/4
133
#define FREQ_GEN_PRSC_8    2 // CLK/8
134
#define FREQ_GEN_PRSC_64   3 // CLK/64
135
#define FREQ_GEN_PRSC_128  4 // CLK/128
136
#define FREQ_GEN_PRSC_1024 5 // CLK/1024
137
#define FREQ_GEN_PRSC_2048 6 // CLK/2048
138
#define FREQ_GEN_PRSC_4096 7 // CLK/4096
139
 
140
 
141
// ----------------------------------------------------------------------------
142
// Wishbone Bus Adapter (WB32)
143
// ----------------------------------------------------------------------------
144
#define WB32_CT  (*(REG16 0xFF90)) // r/w: control register
145
#define WB32_LRA (*(REG16 0xFF92)) // -/w: low address for read transfer
146
#define WB32_HRA (*(REG16 0xFF94)) // -/w: high address for read transfer (+trigger)
147
#define WB32_LWA (*(REG16 0xFF96)) // -/w: low address for write transfer
148
#define WB32_HWA (*(REG16 0xFF98)) // -/w: high address for write transfer (+trigger)
149
#define WB32_LD  (*(REG16 0xFF9A)) // r/w: low data
150
#define WB32_HD  (*(REG16 0xFF9C)) // r/w: high data
151
//#define reserved (*(REG16 0xFF9E)) // -/-: reserved
152
 
153
// WB32 - 32-bit register access
154
#define WB32_RA_32bit (*(REG32 (&WB32_LRA))) // -/w: address for read transfer (+trigger)
155
#define WB32_WA_32bit (*(REG32 (&WB32_LWA))) // -/w: address for write transfer (+trigger)
156
#define WB32_D_32bit  (*(REG32 (&WB32_LD)))  // r/w: read/write data (for 32-bit access)
157
 
158
// WB32 control register
159
#define WB32_CT_WBSEL0   0 // -/w: wishbone data byte enable bit 0
160
#define WB32_CT_WBSEL1   1 // -/w: wishbone data byte enable bit 1
161
#define WB32_CT_WBSEL2   2 // -/w: wishbone data byte enable bit 2
162
#define WB32_CT_WBSEL3   3 // -/w: wishbone data byte enable bit 3
163
#define WB32_CT_PENDING 15 // r/-: pending transfer
164
 
165
 
166
// ----------------------------------------------------------------------------
167
// Universal Asynchronous Receiver and Transmitter (UART)
168
// ----------------------------------------------------------------------------
169
#define UART_CT  (*(REG16 0xFFA0)) // r/w: control register
170
#define UART_RTX (*(REG16 0xFFA2)) // r/w: receive/transmit register
171
 
172
// UART control register
173
#define UART_CT_BAUD0     0 // r/w: baud config bit 0
174
#define UART_CT_BAUD1     1 // r/w: baud config bit 1
175
#define UART_CT_BAUD2     2 // r/w: baud config bit 2
176
#define UART_CT_BAUD3     3 // r/w: baud config bit 3
177
#define UART_CT_BAUD4     4 // r/w: baud config bit 4
178
#define UART_CT_BAUD5     5 // r/w: baud config bit 5
179
#define UART_CT_BAUD6     6 // r/w: baud config bit 6
180
#define UART_CT_BAUD7     7 // r/w: baud config bit 7
181
#define UART_CT_PRSC0     8 // r/w: baud presclaer bit 0
182
#define UART_CT_PRSC1     9 // r/w: baud presclaer bit 1
183
#define UART_CT_PRSC2    10 // r/w: baud presclaer bit 2
184
#define UART_CT_RXOR     11 // r/-: RX data overrun
185
#define UART_CT_EN       12 // r/w: UART enable
186
#define UART_CT_RX_IRQ   13 // r/w: Rx done interrupt enable
187
#define UART_CT_TX_IRQ   14 // r/w: Tx done interrupt enable
188
#define UART_CT_TX_BUSY  15 // r/-: transmitter busy
189
 
190
// UART RTX register flags
191
#define UART_RTX_AVAIL 15 // r/-: uart receiver data available
192
 
193
// clock prescalers 
194
#define UART_PRSC_2    0 // CLK/2
195
#define UART_PRSC_4    1 // CLK/4
196
#define UART_PRSC_8    2 // CLK/8
197
#define UART_PRSC_64   3 // CLK/64
198
#define UART_PRSC_128  4 // CLK/128
199
#define UART_PRSC_1024 5 // CLK/1024
200
#define UART_PRSC_2048 6 // CLK/2048
201
#define UART_PRSC_4096 7 // CLK/4096
202
 
203
 
204
// ----------------------------------------------------------------------------
205
// Serial Peripheral Interface (SPI)
206
// ----------------------------------------------------------------------------
207
#define SPI_CT  (*(REG16 0xFFA4)) // r/w: control register
208
#define SPI_RTX (*(REG16 0xFFA6)) // r/w: receive/transmit register
209
 
210
// SPI control register
211
#define SPI_CT_CS_SEL0  0 // r/w: spi CS 0
212
#define SPI_CT_CS_SEL1  1 // r/w: spi CS 1
213
#define SPI_CT_CS_SEL2  2 // r/w: spi CS 2
214
#define SPI_CT_CS_SEL3  3 // r/w: spi CS 3
215
#define SPI_CT_CS_SEL4  4 // r/w: spi CS 4
216
#define SPI_CT_CS_SEL5  5 // r/w: spi CS 5
217
#define SPI_CT_EN       6 // r/w: spi enable
218
#define SPI_CT_CPHA     7 // r/w: spi clock phase (idle polarity = '0')
219
#define SPI_CT_IRQ      8 // r/w: spi transmission done interrupt enable
220
#define SPI_CT_PRSC0    9 // r/w: spi clock prescaler select bit 0
221
#define SPI_CT_PRSC1   10 // r/w: spi clock prescaler select bit 1
222
#define SPI_CT_PRSC2   11 // r/w: spi clock prescaler select bit 2
223
#define SPI_CT_DIR     12 // r/w: shift direction (0: MSB first, 1: LSB first)
224
#define SPI_CT_SIZE    13 // r/w: 0 = 8-bit, 1 = 16-bit
225
// ...
226
#define SPI_CT_BUSY    15 // r/-: spi transceiver is busy
227
 
228
// clock prescalers 
229
#define SPI_PRSC_2    0 // CLK/2
230
#define SPI_PRSC_4    1 // CLK/4
231
#define SPI_PRSC_8    2 // CLK/8
232
#define SPI_PRSC_64   3 // CLK/64
233
#define SPI_PRSC_128  4 // CLK/128
234
#define SPI_PRSC_1024 5 // CLK/1024
235
#define SPI_PRSC_2048 6 // CLK/2048
236
#define SPI_PRSC_4096 7 // CLK/4096
237
 
238
 
239
// ----------------------------------------------------------------------------
240
// General Purpose Inputs/Outputs (GPIO)
241
// ----------------------------------------------------------------------------
242
#define GPIO_IRQMASK (*(REG16 0xFFA8)) // -/w: irq mask register
243
#define GPIO_INPUT   (*(ROM16 0xFFAA)) // r/-: parallel input
244
#define GPIO_OUTPUT  (*(REG16 0xFFAC)) // r/w: parallel output
245
//#define reserved   (*(REG16 0xFFAE)) // reserved
246
 
247
 
248
// ----------------------------------------------------------------------------
249
// High-Precision Timer (TIMER)
250
// ----------------------------------------------------------------------------
251
#define TMR_CT     (*(REG16 0xFFB0)) // r/w: control register
252
#define TMR_CNT    (*(ROM16 0xFFB2)) // r/-: counter register
253
#define TMR_THRES  (*(REG16 0xFFB4)) // -/w: threshold register
254
//#define reserved (*(REG16 0xFFB6)) // reserved
255
 
256
// Timer control register
257
#define TMR_CT_EN     0 // r/w: timer unit global enable
258
#define TMR_CT_ARST   1 // r/w: auto reset on match
259
#define TMR_CT_IRQ    2 // r/w: interrupt enable
260
#define TMR_CT_RUN    3 // r/w: start/stop timer
261
#define TMR_CT_PRSC0  4 // r/w: clock prescaler select bit 0
262
#define TMR_CT_PRSC1  5 // r/w: clock prescaler select bit 1
263
#define TMR_CT_PRSC2  6 // r/w: clock prescaler select bit 2
264
 
265
// Timer clock prescaler select:
266
#define TMR_PRSC_2    0 // CLK/2
267
#define TMR_PRSC_4    1 // CLK/4
268
#define TMR_PRSC_8    2 // CLK/8
269
#define TMR_PRSC_64   3 // CLK/64
270
#define TMR_PRSC_128  4 // CLK/128
271
#define TMR_PRSC_1024 5 // CLK/1024
272
#define TMR_PRSC_2048 6 // CLK/2048
273
#define TMR_PRSC_4096 7 // CLK/4096
274
 
275
 
276
// ----------------------------------------------------------------------------
277
// Watchdog Timer (WTD)
278
// ----------------------------------------------------------------------------
279
#define WDT_CT (*(REG16 0xFFB8)) // r/w: Watchdog control register
280
 
281
// Watchdog control register
282
#define WDT_CT_PASSWORD 0x47 // must be set in the upper 8 bits of the WDT CTRL register
283
#define WDT_CT_PRSC0    0 // r/w: clock prescaler select bit 0
284
#define WDT_CT_PRSC1    1 // r/w: clock prescaler select bit 1
285
#define WDT_CT_PRSC2    2 // r/w: clock prescaler select bit 2
286
#define WDT_CT_EN       3 // r/w: WDT enable
287
#define WDT_CT_RCAUSE   4 // r/-: reset cause (0: external, 1: watchdog timeout)
288
#define WDT_CT_RPWFAIL  5 // r/-: watchdog resed caused by wrong WDT access password
289
 
290
// Watchdog clock prescaler select:
291
#define WDT_PRSC_2    0 // CLK/2
292
#define WDT_PRSC_4    1 // CLK/4
293
#define WDT_PRSC_8    2 // CLK/8
294
#define WDT_PRSC_64   3 // CLK/64
295
#define WDT_PRSC_128  4 // CLK/128
296
#define WDT_PRSC_1024 5 // CLK/1024
297
#define WDT_PRSC_2048 6 // CLK/2048
298
#define WDT_PRSC_4096 7 // CLK/4096
299
 
300
 
301
// ----------------------------------------------------------------------------
302
// Cyclic Redundancy Check (CRC16/32)
303
// ----------------------------------------------------------------------------
304
#define CRC_POLY_LO (*(REG16 0xFFC0)) // -/w: low part of polynomial
305
#define CRC_POLY_HI (*(REG16 0xFFC2)) // -/w: high part of polynomial
306
#define CRC_CRC16IN (*(REG16 0xFFC4)) // -/w: input for CRC16
307
#define CRC_CRC32IN (*(REG16 0xFFC6)) // -/w: input for CRC32
308
//#define ???       (*(REG16 0xFFC8)) // -/-: reserved
309
//#define ???       (*(REG16 0xFFCA)) // -/-: reserved
310
#define CRC_RESX    (*(REG16 0xFFCC)) // r/w: crc shift register low
311
#define CRC_RESY    (*(REG16 0xFFCE)) // r/w: crc shift register high
312
 
313
#define CRC_POLY32bit (*(REG32 (&CRC_POLY_LO))) // -/w: write polynomial as 32-bit data word
314
#define CRC_R32bit    (*(REG32 (&CRC_RESX)))    // r/w: crc shift register as 32-bit data word
315
 
316
 
317
// ----------------------------------------------------------------------------
318
// Custom Functions Unit (CFU)
319
// ----------------------------------------------------------------------------
320
#define CFU_REG0 (*(REG16 0xFFD0)) // r/w: user defined...
321
#define CFU_REG1 (*(REG16 0xFFD2)) // r/w: user defined...
322
#define CFU_REG2 (*(REG16 0xFFD4)) // r/w: user defined...
323
#define CFU_REG3 (*(REG16 0xFFD6)) // r/w: user defined...
324
#define CFU_REG4 (*(REG16 0xFFD8)) // r/w: user defined...
325
#define CFU_REG5 (*(REG16 0xFFDA)) // r/w: user defined...
326
#define CFU_REG6 (*(REG16 0xFFDC)) // r/w: user defined...
327
#define CFU_REG7 (*(REG16 0xFFDE)) // r/w: user defined...
328
 
329
 
330
// ----------------------------------------------------------------------------
331
// Pulse Width Modulation Controller (PWM)
332
// ----------------------------------------------------------------------------
333
#define PWM_CT   (*(REG16 0xFFE0)) // r/w: control register
334
#define PWM_CH10 (*(REG16 0xFFE2)) // r/w: duty cycle channel 1 and 0
335
#define PWM_CH32 (*(REG16 0xFFE4)) // -/w: duty cycle channel 3 and 2
336
 
337
// PWM controller control register
338
#define PWM_CT_EN       0 // -/w: PWM enable
339
#define PWM_CT_PRSC0    1 // -/w: clock prescaler select bit 0
340
#define PWM_CT_PRSC1    2 // -/w: clock prescaler select bit 1
341
#define PWM_CT_PRSC2    3 // -/w: clock prescaler select bit 2
342
#define PWM_CT_GPIO_PWM 4 // -/w: use channel 3 for PWM modulation of GPIO unit's output port
343
#define PWM_CT_SIZE_SEL 5 // -/w: cnt size select (0 = 4-bit, 1 = 8-bit)
344
 
345
// PWM clock prescaler select:
346
#define PWM_PRSC_2    0 // CLK/2
347
#define PWM_PRSC_4    1 // CLK/4
348
#define PWM_PRSC_8    2 // CLK/8
349
#define PWM_PRSC_64   3 // CLK/64
350
#define PWM_PRSC_128  4 // CLK/128
351
#define PWM_PRSC_1024 5 // CLK/1024
352
#define PWM_PRSC_2048 6 // CLK/2048
353
#define PWM_PRSC_4096 7 // CLK/4096
354
 
355
 
356
// ----------------------------------------------------------------------------
357
// Two Wire Serial Interface (TWI)
358
// ----------------------------------------------------------------------------
359
#define TWI_CT   (*(REG16 0xFFE8)) // r/w: control register
360
#define TWI_DATA (*(REG16 0xFFEA)) // r/w: RX (r) / TX (w) data
361
 
362
// TWI control register
363
#define TWI_CT_EN       0 // r/w: TWI enable
364
#define TWI_CT_START    1 // -/w: generate START condition
365
#define TWI_CT_STOP     2 // -/w: generate STOP condition
366
#define TWI_CT_BUSY     3 // r/-: TWI busy
367
#define TWI_CT_PRSC0    4 // r/w: clock prescaler select bit 0
368
#define TWI_CT_PRSC1    5 // r/w: clock prescaler select bit 1
369
#define TWI_CT_PRSC2    6 // r/w: clock prescaler select bit 2
370
#define TWI_CT_IRQ_EN   7 // r/w: transmission done interrupt enable
371
#define TWI_CT_MACK     8 // r/w: send ack by master after transmission
372
 
373
// TWI clock prescaler select:
374
#define TWI_PRSC_2    0 // CLK/2
375
#define TWI_PRSC_4    1 // CLK/4
376
#define TWI_PRSC_8    2 // CLK/8
377
#define TWI_PRSC_64   3 // CLK/64
378
#define TWI_PRSC_128  4 // CLK/128
379
#define TWI_PRSC_1024 5 // CLK/1024
380
#define TWI_PRSC_2048 6 // CLK/2048
381
#define TWI_PRSC_4096 7 // CLK/4096
382
 
383
// TWI data register flags
384
#define TWI_DT_ACK    15 // r/-: ACK received
385
 
386
 
387
// ----------------------------------------------------------------------------
388
// True Random Number Generator (TRNG)
389
// ----------------------------------------------------------------------------
390
#define TRNG_CT (*(REG16 0xFFEC)) // r/w: control register
391
 
392
// TRNG control register
393
#define TRNG_CT_DATA0     0 // r/-: TRNG random data byte bit 0
394
#define TRNG_CT_DATA1     1 // r/-: TRNG random data byte bit 1
395
#define TRNG_CT_DATA2     2 // r/-: TRNG random data byte bit 2
396
#define TRNG_CT_DATA3     3 // r/-: TRNG random data byte bit 3
397
#define TRNG_CT_DATA4     4 // r/-: TRNG random data byte bit 4
398
#define TRNG_CT_DATA5     5 // r/-: TRNG random data byte bit 5
399
#define TRNG_CT_DATA6     6 // r/-: TRNG random data byte bit 6
400
#define TRNG_CT_DATA7     7 // r/-: TRNG random data byte bit 7
401
#define TRNG_CT_DATA8     8 // r/-: TRNG random data byte bit 8
402
#define TRNG_CT_DATA9     9 // r/-: TRNG random data byte bit 9
403
#define TRNG_CT_DATA10   10 // r/-: TRNG random data byte bit 10
404
#define TRNG_CT_DATA11   11 // r/-: TRNG random data byte bit 11
405
// --
406
#define TRNG_CT_TAP00_EN  0 // -/w: Activate tap 0 switch
407
#define TRNG_CT_TAP01_EN  1 // -/w: Activate tap 1 switch
408
#define TRNG_CT_TAP02_EN  2 // -/w: Activate tap 2 switch
409
#define TRNG_CT_TAP03_EN  3 // -/w: Activate tap 3 switch
410
#define TRNG_CT_TAP04_EN  4 // -/w: Activate tap 4 switch
411
#define TRNG_CT_TAP05_EN  5 // -/w: Activate tap 5 switch
412
#define TRNG_CT_TAP06_EN  6 // -/w: Activate tap 6 switch
413
#define TRNG_CT_TAP07_EN  7 // -/w: Activate tap 7 switch
414
#define TRNG_CT_TAP08_EN  8 // -/w: Activate tap 8 switch
415
#define TRNG_CT_TAP09_EN  9 // -/w: Activate tap 9 switch
416
#define TRNG_CT_TAP10_EN 10 // -/w: Activate tap 10 switch
417
#define TRNG_CT_TAP11_EN 11 // -/w: Activate tap 11 switch
418
#define TRNG_CT_TAP12_EN 12 // -/w: Activate tap 12 switch
419
#define TRNG_CT_TAP13_EN 13 // -/w: Activate tap 13 switch
420
// --
421
#define TRNG_CT_EN       14 // r/w: TRNG enable
422
#define TRNG_CT_VALID    15 // r/-: TRNG output byte is valid
423
 
424
 
425
 
426
// ----------------------------------------------------------------------------
427
// External Interrupts Controller (EXIRQ)
428
// ----------------------------------------------------------------------------
429
#define EXIRQ_CT (*(REG16 0xFFEE)) // r/w: control register
430
 
431
// EXIRQ control register
432
#define EXIRQ_CT_SEL0         0 // r/w: IRQ source bit 0 / SW_IRQ select
433
#define EXIRQ_CT_SEL1         1 // r/w: IRQ source bit 1 / SW_IRQ select
434
#define EXIRQ_CT_SEL2         2 // r/w: IRQ source bit 2 / SW_IRQ select
435
#define EXIRQ_CT_EN           3 // r/w: unit enable
436
#define EXIRQ_CT_SW_IRQ       4 // -/w: use irq_sel as SW IRQ trigger, auto-clears
437
#define EXIRQ_CT_ACK_IRQ      5 // -/w: use irq_sel as ACK select, auto-clears
438
// ...
439
#define EXIRQ_CT_IRQ0_EN      8 // r/w: Enable IRQ channel 0
440
#define EXIRQ_CT_IRQ1_EN      9 // r/w: Enable IRQ channel 1
441
#define EXIRQ_CT_IRQ2_EN     10 // r/w: Enable IRQ channel 2
442
#define EXIRQ_CT_IRQ3_EN     11 // r/w: Enable IRQ channel 3
443
#define EXIRQ_CT_IRQ4_EN     12 // r/w: Enable IRQ channel 4
444
#define EXIRQ_CT_IRQ5_EN     13 // r/w: Enable IRQ channel 5
445
#define EXIRQ_CT_IRQ6_EN     14 // r/w: Enable IRQ channel 6
446
#define EXIRQ_CT_IRQ7_EN     15 // r/w: Enable IRQ channel 7
447
 
448
 
449
// ----------------------------------------------------------------------------
450
// System Configuration (SYSCONFIG)
451
// ----------------------------------------------------------------------------
452
#define CPUID0 (*(ROM16 0xFFF0)) // r/-: HW version number
453
#define CPUID1 (*(ROM16 0xFFF2)) // r/-: synthesized system features
454
#define CPUID2 (*(ROM16 0xFFF4)) // r/-: custom user code
455
#define CPUID3 (*(ROM16 0xFFF6)) // r/-: IMEM/ROM size in bytes
456
#define CPUID4 (*(ROM16 0xFFF8)) // r/-: advanced/experimental hardware configuration features
457
#define CPUID5 (*(ROM16 0xFFFA)) // r/-: DMEM/RAM size in bytes
458
#define CPUID6 (*(ROM16 0xFFFC)) // r/-: clock speed (in Hz) low part
459
#define CPUID7 (*(ROM16 0xFFFE)) // r/-: clock speed (in Hz) high part
460
 
461
// Aliases
462
#define HW_VERSION    CPUID0 // r/-: HW version number
463
#define SYS_FEATURES  CPUID1 // r/-: synthesized system features
464
#define USER_CODE     CPUID2 // r/-: custom user code
465
#define IMEM_SIZE     CPUID3 // r/-: IMEM/ROM size in bytes
466
#define NX_FEATURES   CPUID4 // r/-: advanced/experimental hardware configuration features
467
#define DMEM_SIZE     CPUID5 // r/-: DMEM/RAM size in bytes
468
#define CLOCKSPEED_LO CPUID6 // r/-: clock speed (in Hz) low part
469
#define CLOCKSPEED_HI CPUID7 // r/-: clock speed (in Hz) high part
470
 
471
// SysConfig - 32-bit register access
472
#define CLOCKSPEED_32bit (*(ROM32 (&CLOCKSPEED_LO))) // r/-: clock speed (in Hz)
473
 
474
// SYS features
475
#define SYS_MULDIV_EN    0 // r/-: MULDIV synthesized
476
#define SYS_WB32_EN      1 // r/-: WB32 synthesized
477
#define SYS_WDT_EN       2 // r/-: WDT synthesized
478
#define SYS_GPIO_EN      3 // r/-: GPIO synthesized
479
#define SYS_TIMER_EN     4 // r/-: TIMER synthesized
480
#define SYS_UART_EN      5 // r/-: UART synthesized
481
#define SYS_FREQ_GEN_EN  6 // r/-: FREQ_GEN synthesized
482
#define SYS_BTLD_EN      7 // r/-: Bootloader installed and enabled
483
#define SYS_IROM_EN      8 // r/-: Implement IMEM as true ROM
484
#define SYS_CRC_EN       9 // r/-: CRC synthesized
485
#define SYS_CFU_EN      10 // r/-: CFU synthesized
486
#define SYS_PWM_EN      11 // r/-: PWM controller synthesized
487
#define SYS_TWI_EN      12 // r/-: TWI synthesized
488
#define SYS_SPI_EN      13 // r/-: SPI synthesized
489
#define SYS_TRNG_EN     14 // r/-: TRNG synthesized
490
#define SYS_EXIRQ_EN    15 // r/-: EXIRQ synthesized
491
 
492
// NX features (advanced/experimental features)
493
#define NX_DSP_MUL_EN   0 // r/-: using DSP-blocks for MULDIV.multiplier
494
#define NX_XALU_EN      1 // r/-: implement eXtended ALU functions
495
#define NX_LOWPOWER_EN  2 // r/-: use low-power implementation (experimental!)
496
 
497
 
498
// ----------------------------------------------------------------------------
499
// ~~ EXPERIMENTAL ~~
500
// ----------------------------------------------------------------------------
501
#define NEO430_DEVNULL (*(REG16 0xFF00)) // r/w: read: 0, write: no effect
502
 
503
 
504
// ----------------------------------------------------------------------------
505
// Include all IO library headers
506
// ----------------------------------------------------------------------------
507
#include "neo430_cpu.h"
508
#include "neo430_crc.h"
509
#include "neo430_exirq.h"
510
#include "neo430_freq_gen.h"
511
#include "neo430_gpio.h"
512
#include "neo430_muldiv.h"
513
#include "neo430_pwm.h"
514
#include "neo430_spi.h"
515
#include "neo430_timer.h"
516
#include "neo430_trng.h"
517
#include "neo430_twi.h"
518
#include "neo430_uart.h"
519
#include "neo430_wdt.h"
520
#include "neo430_wishbone.h"
521
 
522
 
523
#endif // neo430_h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.