1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
/*
* @brief LPC5410X System & Control driver inclusion file
*
* @note
* Copyright(C) NXP Semiconductors, 2014
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under any
* patent, copyright, mask work right, or any other intellectual property rights in
* or to any products. NXP Semiconductors reserves the right to make changes
* in the software without notification. NXP Semiconductors also makes no
* representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#ifndef __SYSCON_5410X_H_
#define __SYSCON_5410X_H_
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup SYSCON_5410X CHIP: LPC5410X System and Control Driver
* @ingroup CHIP_5410X_DRIVERS
* @{
*/
/**
* @brief LPC5410X Main system configuration register block structure
*/
typedef struct {
__IO uint32_t SYSMEMREMAP; /*!< System Remap register */
__I uint32_t RESERVED0[4];
__IO uint32_t SYSTCKCAL; /*!< System Tick Calibration register */
__I uint32_t RESERVED1[1];
__IO uint32_t NMISRC; /*!< NMI Source select register */
__IO uint32_t ASYNCAPBCTRL; /*!< Asynch APB chiplet control register */
__I uint32_t RESERVED2[7];
__IO uint32_t SYSRSTSTAT; /*!< System Reset Stat register */
__IO uint32_t PRESETCTRL[2]; /*!< Peripheral Reset Ctrl register */
__IO uint32_t PRESETCTRLSET[2]; /*!< Peripheral Reset Ctrl Set register */
__IO uint32_t PRESETCTRLCLR[2]; /*!< Peripheral Reset Ctrl Clr register */
__IO uint32_t PIOPORCAP[2]; /*!< PIO Power-On Reset Capture register */
__I uint32_t RESERVED3[1];
__IO uint32_t PIORESCAP[2]; /*!< PIO Pad Reset Capture register */
__I uint32_t RESERVED4[4];
__IO uint32_t MAINCLKSELA; /*!< Main Clk sel Source Sel A register */
__IO uint32_t MAINCLKSELB; /*!< Main Clk sel Source Sel B register */
__I uint32_t RESERVED5;
__IO uint32_t ADCCLKSEL; /*!< ADC Async Clk Sel register */
__I uint32_t RESERVED6;
__IO uint32_t CLKOUTSELA; /*!< Clk Out Sel Source A register */
__IO uint32_t CLKOUTSELB; /*!< Clk Out Sel Source B register */
__I uint32_t RESERVED7;
__IO uint32_t SYSPLLCLKSEL; /*!< System PLL Clk Selregister */
__I uint32_t RESERVED8[7];
__IO uint32_t AHBCLKCTRL[2]; /*!< AHB Peripheral Clk Enable register */
__IO uint32_t AHBCLKCTRLSET[2]; /*!< AHB Peripheral Clk Enable Set register */
__IO uint32_t AHBCLKCTRLCLR[2]; /*!< AHB Peripheral Clk Enable Clr register */
__I uint32_t RESERVED9[2];
__IO uint32_t SYSTICKCLKDIV; /*!< Systick Clock divider register */
__I uint32_t RESERVED10[7];
__IO uint32_t AHBCLKDIV; /*!< Main Clk Divider register */
__IO uint32_t RESERVED11;
__IO uint32_t ADCCLKDIV; /*!< ADC Async Clk Divider register */
__IO uint32_t CLKOUTDIV; /*!< Clk Out Divider register */
__I uint32_t RESERVED12[4];
__IO uint32_t FREQMECTRL; /*!< Frequency Measure Control register */
__IO uint32_t FLASHCFG; /*!< Flash Config register */
__I uint32_t RESERVED13[8];
__IO uint32_t FIFOCTRL; /*!< VFIFO control register */
__I uint32_t RESERVED14[14];
__I uint32_t RESERVED15[1];
__I uint32_t RESERVED16[2];
__IO uint32_t RTCOSCCTRL; /*!< RTC Oscillator Control register */
__I uint32_t RESERVED17[7];
__IO uint32_t SYSPLLCTRL; /*!< System PLL control register */
__IO uint32_t SYSPLLSTAT; /*!< PLL status register */
__IO uint32_t SYSPLLNDEC; /*!< PLL N decoder register */
__IO uint32_t SYSPLLPDEC; /*!< PLL P decoder register */
__IO uint32_t SYSPLLSSCTRL[2]; /*!< Spread Spectrum control registers */
__I uint32_t RESERVED18[18];
__IO uint32_t PDRUNCFG; /*!< Power Down Run Config register */
__IO uint32_t PDRUNCFGSET; /*!< Power Down Run Config Set register */
__IO uint32_t PDRUNCFGCLR; /*!< Power Down Run Config Clr register */
__I uint32_t RESERVED19[9];
__IO uint32_t STARTERP[2]; /*!< Start Signal Enable Register */
__IO uint32_t STARTERSET[2]; /*!< Start Signal Enable Set Register */
__IO uint32_t STARTERCLR[2]; /*!< Start Signal Enable Clr Register */
__I uint32_t RESERVED20[42];
__I uint32_t RESERVED20A[4];
__I uint32_t RESERVED21[57];
__IO uint32_t JTAG_IDCODE;
__IO uint32_t DEVICE_ID0; /*!< Boot ROM and die revision register */
__IO uint32_t DEVICE_ID1; /*!< Boot ROM and die revision register */
} LPC_SYSCON_T;
/**
* @brief LPC5410X Asynchronous system configuration register block structure
*/
typedef struct {
__IO uint32_t AYSNCPRESETCTRL; /*!< peripheral reset register */
__IO uint32_t ASYNCPRESETCTRLSET; /*!< peripheral reset Set register */
__IO uint32_t ASYNCPRESETCTRLCLR; /*!< peripheral reset Clr register */
__I uint32_t RESERVED0;
__IO uint32_t ASYNCAPBCLKCTRL; /*!< clk enable register */
__IO uint32_t ASYNCAPBCLKCTRLSET; /*!< clk enable Set register */
__IO uint32_t ASYNCAPBCLKCTRLCLR; /*!< clk enable Clr register */
__I uint32_t RESERVED1;
__IO uint32_t ASYNCAPBCLKSELA; /*!< clk source mux A register */
__IO uint32_t ASYNCAPBCLKSELB; /*!< clk source mux B register */
__IO uint32_t ASYNCCLKDIV; /*!< clk div register */
__I uint32_t RESERVED2;
__IO uint32_t FRGCTRL; /*!< Fraction Rate Generator Ctrl register */
} LPC_ASYNC_SYSCON_T;
/**
* System memory remap modes used to remap interrupt vectors
*/
typedef enum CHIP_SYSCON_BOOT_MODE_REMAP {
REMAP_BOOT_LOADER_MODE, /*!< Interrupt vectors are re-mapped to Boot ROM */
REMAP_USER_RAM_MODE, /*!< Interrupt vectors are re-mapped to user Static RAM */
REMAP_USER_FLASH_MODE /*!< Interrupt vectors are not re-mapped and reside in Flash */
} CHIP_SYSCON_BOOT_MODE_REMAP_T;
/**
* @brief Re-map interrupt vectors
* @param remap : system memory map value
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_Map(CHIP_SYSCON_BOOT_MODE_REMAP_T remap)
{
LPC_SYSCON->SYSMEMREMAP = (uint32_t) remap;
}
/**
* @brief Get system remap setting
* @return System remap setting
*/
STATIC INLINE CHIP_SYSCON_BOOT_MODE_REMAP_T Chip_SYSCON_GetMemoryMap(void)
{
return (CHIP_SYSCON_BOOT_MODE_REMAP_T) LPC_SYSCON->SYSMEMREMAP;
}
/**
* @brief Set System tick timer calibration value
* @param sysCalVal : System tick timer calibration value
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_SetSYSTCKCAL(uint32_t sysCalVal)
{
LPC_SYSCON->SYSTCKCAL = sysCalVal;
}
/**
* Non-Maskable Interrupt Enable/Disable value
*/
#define SYSCON_NMISRC_M0_ENABLE ((uint32_t) 1 << 30) /*!< Enable the Non-Maskable Interrupt M0 (NMI) source */
#define SYSCON_NMISRC_M4_ENABLE ((uint32_t) 1 << 31) /*!< Enable the Non-Maskable Interrupt M4 (NMI) source */
/**
* @brief Set source for non-maskable interrupt (NMI)
* @param intsrc : IRQ number to assign to the NMI
* @return Nothing
* @note The NMI source will be disabled upon exiting this function. Use the
* Chip_SYSCON_EnableNMISource() function to enable the NMI source.
*/
void Chip_SYSCON_SetNMISource(uint32_t intsrc);
/**
* @brief Enable interrupt used for NMI source
* @return Nothing
*/
void Chip_SYSCON_EnableNMISource(void);
/**
* @brief Disable interrupt used for NMI source
* @return Nothing
*/
void Chip_SYSCON_DisableNMISource(void);
/**
* @brief Enable or disable asynchronous APB bridge and subsystem
* @param enable : true to enable, false to disable
* @return Nothing
* @note This bridge must be enabled to access peripherals on the
* associated bridge.
*/
void Chip_SYSCON_Enable_ASYNC_Syscon(bool enable);
/**
* @brief Set UART Fractional divider value
* @param fmul : Fractional multiplier value
* @param fdiv : Fractional divider value (Must always be 0xFF)
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_SetUSARTFRGCtrl(uint8_t fmul, uint8_t fdiv)
{
LPC_ASYNC_SYSCON->FRGCTRL = ((uint32_t) fmul << 8) | fdiv;
}
/**
* System reset status values
*/
#define SYSCON_RST_POR (1 << 0) /*!< POR reset status */
#define SYSCON_RST_EXTRST (1 << 1) /*!< External reset status */
#define SYSCON_RST_WDT (1 << 2) /*!< Watchdog reset status */
#define SYSCON_RST_BOD (1 << 3) /*!< Brown-out detect reset status */
#define SYSCON_RST_SYSRST (1 << 4) /*!< software system reset status */
/**
* @brief Get system reset status
* @return An Or'ed value of SYSCON_RST_*
* @note This function returns the detected reset source(s).
*/
STATIC INLINE uint32_t Chip_SYSCON_GetSystemRSTStatus(void)
{
return LPC_SYSCON->SYSRSTSTAT;
}
/**
* @brief Clear system reset status
* @param reset : An Or'ed value of SYSCON_RST_* status to clear
* @return Nothing
* @note This function clears the specified reset source(s).
*/
STATIC INLINE void Chip_SYSCON_ClearSystemRSTStatus(uint32_t reset)
{
LPC_SYSCON->SYSRSTSTAT = reset;
}
/**
* Peripheral reset identifiers
*/
typedef enum {
/* Peripheral reset enables for PRESETCTRL0 */
RESET_FLASH = 7, /*!< Flash controller */
RESET_FMC, /*!< Flash accelerator */
RESET_INMUX = 11, /*!< Input mux */
RESET_IOCON = 13, /*!< IOCON */
RESET_GPIO0, /*!< GPIO Port 0 */
RESET_GPIO1, /*!< GPIO Port 1 */
RESET_PINT = 18, /*!< Pin interrupt */
RESET_GINT, /*!< Grouped interrupt (GINT) */
RESET_DMA, /*!< DMA */
RESET_CRC, /*!< CRC */
RESET_WWDT, /*!< Watchdog timer */
RESET_RTC, /*!< RTC */
RESET_MAILBOX = 26, /*!< Mailbox */
RESET_ADC0, /*!< ADC0 */
/* Peripheral reset enables for PRESETCTRL1 */
RESET_MRT = 32 + 0, /*!< multi-rate timer */
RESET_RIT, /*!< Repetitive interrupt timer */
RESET_SCT0, /*!< SCT0 */
RESET_FIFO = 32 + 9, /*!< System FIFO */
RESET_UTICK, /*!< Micro-tick Timer */
RESET_TIMER2 = 32 + 22, /*!< TIMER2 */
RESET_TIMER3 = 32 + 26, /*!< TIMER3 */
RESET_TIMER4, /*!< TIMER4 */
/* Async peripheral reset enables for ASYNCPRESETCTRL */
RESET_USART0 = 128 + 1, /*!< UART0 */
RESET_USART1, /*!< UART1 */
RESET_USART2, /*!< UART2 */
RESET_USART3, /*!< UART3 */
RESET_I2C0, /*!< I2C0 */
RESET_I2C1, /*!< I2C1 */
RESET_I2C2, /*!< I2C2 */
RESET_SPI0 = 128 + 9, /*!< SPI0 */
RESET_SPI1, /*!< SPI1 */
RESET_TIMER0 = 128 + 13, /*!< TIMER0 */
RESET_TIMER1, /*!< TIMER1 */
RESET_FRG0 /*!< FRG */
} CHIP_SYSCON_PERIPH_RESET_T;
/**
* @brief Resets a peripheral
* @param periph : Peripheral to reset
* @return Nothing
* Will assert and de-assert reset for a peripheral.
*/
void Chip_SYSCON_PeriphReset(CHIP_SYSCON_PERIPH_RESET_T periph);
/**
* @brief Read POR captured PIO status
* @param port : 0 for port 0 pins, 1 for port 1 pins, 2 for port 2 pins, etc.
* @return captured Power-On-Reset (POR) PIO status
*/
STATIC INLINE uint32_t Chip_SYSCON_GetPORPIOStatus(uint8_t port)
{
return LPC_SYSCON->PIOPORCAP[port];
}
/**
* @brief Read reset captured PIO status
* @param port : 0 for port 0 pins, 1 for port 1 pins, 2 for port 2 pins, etc.
* @return captured reset PIO status
* @note Used when reset other than a Power-On-Reset (POR) occurs.
*/
STATIC INLINE uint32_t Chip_SYSCON_GetResetPIOStatus(uint8_t port)
{
return LPC_SYSCON->PIORESCAP[port];
}
/**
* @brief Starts a frequency measurement cycle
* @return Nothing
* @note This function is meant to be used with the Chip_INMUX_SetFreqMeasRefClock()
* and Chip_INMUX_SetFreqMeasTargClock() functions.
*/
STATIC INLINE void Chip_SYSCON_StartFreqMeas(void)
{
LPC_SYSCON->FREQMECTRL = 0;
LPC_SYSCON->FREQMECTRL = (1UL << 31);
}
/**
* @brief Indicates when a frequency measurement cycle is complete
* @return true if a measurement cycle is active, otherwise false
*/
STATIC INLINE bool Chip_SYSCON_IsFreqMeasComplete(void)
{
return (bool) ((LPC_SYSCON->FREQMECTRL & (1UL << 31)) == 0);
}
/**
* @brief Returns the raw capture value for a frequency measurement cycle
* @return raw cpature value (this is not a frequency)
*/
STATIC INLINE uint32_t Chip_SYSCON_GetRawFreqMeasCapval(void)
{
return LPC_SYSCON->FREQMECTRL & 0x3FFF;
}
/**
* @brief Returns the computed value for a frequency measurement cycle
* @param refClockRate : Reference clock rate used during the frequency measurement cycle
* @return Computed cpature value
*/
uint32_t Chip_SYSCON_GetCompFreqMeas(uint32_t refClockRate);
/**
* @brief FLASH Access time definitions
*/
typedef enum {
SYSCON_FLASH_1CYCLE = 0, /*!< Flash accesses use 1 CPU clock */
FLASHTIM_20MHZ_CPU = SYSCON_FLASH_1CYCLE,
SYSCON_FLASH_2CYCLE, /*!< Flash accesses use 2 CPU clocks */
SYSCON_FLASH_3CYCLE, /*!< Flash accesses use 3 CPU clocks */
SYSCON_FLASH_4CYCLE, /*!< Flash accesses use 4 CPU clocks */
SYSCON_FLASH_5CYCLE, /*!< Flash accesses use 5 CPU clocks */
SYSCON_FLASH_6CYCLE, /*!< Flash accesses use 6 CPU clocks */
SYSCON_FLASH_7CYCLE, /*!< Flash accesses use 7 CPU clocks */
SYSCON_FLASH_8CYCLE /*!< Flash accesses use 8 CPU clocks */
} SYSCON_FLASHTIM_T;
/**
* @brief Set FLASH memory access time in clocks
* @param clks : Clock cycles for FLASH access
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_SetFLASHAccess(SYSCON_FLASHTIM_T clks)
{
uint32_t tmp;
tmp = LPC_SYSCON->FLASHCFG & ~(0xF << 12);
/* Don't alter lower bits */
LPC_SYSCON->FLASHCFG = tmp | ((uint32_t) clks << 12);
}
/**
* @brief System FIFO bit definitions
*/
#define SYSCON_FIFO_U0TXFIFOEN (1 << 0) /*!< USART0 transmitter FIFO enable bit */
#define SYSCON_FIFO_U1TXFIFOEN (1 << 1) /*!< USART1 transmitter FIFO enable bit */
#define SYSCON_FIFO_U2TXFIFOEN (1 << 2) /*!< USART2 transmitter FIFO enable bit */
#define SYSCON_FIFO_U3TXFIFOEN (1 << 3) /*!< USART3 transmitter FIFO enable bit */
#define SYSCON_FIFO_SPI0TXFIFOEN (1 << 4) /*!< SPI0 transmitter FIFO enable bit */
#define SYSCON_FIFO_SPI1TXFIFOEN (1 << 5) /*!< SPI1 transmitter FIFO enable bit */
#define SYSCON_FIFO_U0RXFIFOEN (1 << 8) /*!< USART0 receiver FIFO enable bit */
#define SYSCON_FIFO_U1RXFIFOEN (1 << 9) /*!< USART1 receiver FIFO enable bit */
#define SYSCON_FIFO_U2RXFIFOEN (1 << 10) /*!< USART2 receiver FIFO enable bit */
#define SYSCON_FIFO_U3RXFIFOEN (1 << 11) /*!< USART3 receiver FIFO enable bit */
#define SYSCON_FIFO_SPI0RXFIFOEN (1 << 12) /*!< SPI0 receiver FIFO enable bit */
#define SYSCON_FIFO_SPI1RXFIFOEN (1 << 13) /*!< SPI1 receiver FIFO enable bit */
/**
* @brief Enable System FIFO(s) for a peripheral
* @param enMask : Or'ed bits or type SYSCON_FIFO_* for enabling system FIFOs
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_EnableSysFIFO(uint32_t enMask)
{
LPC_SYSCON->FIFOCTRL |= enMask;
}
/**
* @brief Disable System FIFO(s) for a peripheral
* @param disMask : Or'ed bits or type SYSCON_FIFO_* for disabling system FIFOs
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_DisableSysFIFO(uint32_t disMask)
{
LPC_SYSCON->FIFOCTRL &= ~disMask;
}
/**
* Power control definition bits (0 = powered, 1 = powered down)
*/
#define SYSCON_PDRUNCFG_PD_IRC_OSC (1 << 3) /*!< IRC oscillator output */
#define SYSCON_PDRUNCFG_PD_IRC (1 << 4) /*!< IRC oscillator */
#define SYSCON_PDRUNCFG_PD_FLASH (1 << 5) /*!< Flash memory */
#define SYSCON_PDRUNCFG_PD_BOD_RST (1 << 7) /*!< Brown-out Detect reset */
#define SYSCON_PDRUNCFG_PD_BOD_INTR (1 << 8) /*!< Brown-out Detect interrupt */
#define SYSCON_PDRUNCFG_PD_ADC0 (1 << 10) /*!< ADC0 */
#define SYSCON_PDRUNCFG_PD_SRAM0A (1 << 13) /*!< First 8 kB of SRAM0 */
#define SYSCON_PDRUNCFG_PD_SRAM0B (1 << 14) /*!< Remaining portion of SRAM0 */
#define SYSCON_PDRUNCFG_PD_SRAM1 (1 << 15) /*!< SRAM1 */
#define SYSCON_PDRUNCFG_PD_SRAM2 (1 << 16) /*!< SRAM2 */
#define SYSCON_PDRUNCFG_PD_ROM (1 << 17) /*!< ROM */
#define SYSCON_PDRUNCFG_PD_VDDA_ENA (1 << 19) /*!< Vdda to the ADC, must be enabled for the ADC to work */
#define SYSCON_PDRUNCFG_PD_WDT_OSC (1 << 20) /*!< Watchdog oscillator */
#define SYSCON_PDRUNCFG_PD_SYS_PLL (1 << 22) /*!< PLL0 */
#define SYSCON_PDRUNCFG_PD_VREFP (1 << 23) /*!< Vrefp to the ADC, must be enabled for the ADC to work */
#define SYSCON_PDRUNCFG_PD_32K_OSC (1 << 24) /*!< 32 kHz RTC oscillator */
/**
* @brief Power up one or more blocks or peripherals
* @return OR'ed values of SYSCON_PDRUNCFG_* values
* @note A high state indicates the peripheral is powered down.
*/
STATIC INLINE uint32_t Chip_SYSCON_GetPowerStates(void)
{
return LPC_SYSCON->PDRUNCFG;
}
/**
* @brief Power down one or more blocks or peripherals
* @param powerdownmask : OR'ed values of SYSCON_PDRUNCFG_* values
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_PowerDown(uint32_t powerdownmask)
{
/* Disable peripheral states by setting high */
LPC_SYSCON->PDRUNCFGSET = powerdownmask;
}
/**
* @brief Power up one or more blocks or peripherals
* @param powerupmask : OR'ed values of SYSCON_PDRUNCFG_* values
* @return Nothing
*/
void Chip_SYSCON_PowerUp(uint32_t powerupmask);
/**
* Start enable enumerations - for enabling and disabling peripheral wakeup
*/
typedef enum {
SYSCON_STARTER_WWDT = 0,
SYSCON_STARTER_BOD,
SYSCON_STARTER_DMA = 3,
SYSCON_STARTER_GINT0,
SYSCON_STARTER_PINT0,
SYSCON_STARTER_PINT1,
SYSCON_STARTER_PINT2,
SYSCON_STARTER_PINT3,
SYSCON_STARTER_UTICK,
SYSCON_STARTER_MRT,
SYSCON_STARTER_TIMER0,
SYSCON_STARTER_TIMER1,
SYSCON_STARTER_TIMER2,
SYSCON_STARTER_TIMER3,
SYSCON_STARTER_TIMER4,
SYSCON_STARTER_SCT0,
SYSCON_STARTER_USART0,
SYSCON_STARTER_USART1,
SYSCON_STARTER_USART2,
SYSCON_STARTER_USART3,
SYSCON_STARTER_I2C0,
SYSCON_STARTER_I2C1,
SYSCON_STARTER_I2C2,
SYSCON_STARTER_SPI0,
SYSCON_STARTER_SPI1,
SYSCON_STARTER_ADC0_SEQA,
SYSCON_STARTER_ADC0_SEQB,
SYSCON_STARTER_ADC0_THCMP,
SYSCON_STARTER_RTC,
SYSCON_STARTER_MAILBOX = 31,
/* For M4 only */
SYSCON_STARTER_GINT1 = 32 + 0,
SYSCON_STARTER_PINT4,
SYSCON_STARTER_PINT5,
SYSCON_STARTER_PINT6,
SYSCON_STARTER_PINT7,
SYSCON_STARTER_RIT = 32 + 8,
} CHIP_SYSCON_WAKEUP_T;
/**
* @brief Enables a pin's (PINT) wakeup logic
* @param periphId : Peripheral identifier
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_EnableWakeup(CHIP_SYSCON_WAKEUP_T periphId)
{
uint32_t pid = (uint32_t) periphId;
if (pid < 32) {
LPC_SYSCON->STARTERSET[0] = (1 << pid);
}
else {
LPC_SYSCON->STARTERSET[1] = (1 << (pid - 32));
}
}
/**
* @brief Disables peripheral's wakeup logic
* @param periphId : Peripheral identifier
* @return Nothing
*/
STATIC INLINE void Chip_SYSCON_DisableWakeup(CHIP_SYSCON_WAKEUP_T periphId)
{
uint32_t pid = (uint32_t) periphId;
if (pid < 32) {
LPC_SYSCON->STARTERCLR[0] = (1 << pid);
}
else {
LPC_SYSCON->STARTERCLR[1] = (1 << (pid - 32));
}
}
/**
* @brief Return the device ID
* @return Device ID
*/
STATIC INLINE uint32_t Chip_SYSCON_GetDeviceID(void)
{
return LPC_SYSCON->DEVICE_ID0;
}
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __SYSCON_5410X_H_ */
|