| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sct_blinky.c
Go to the documentation of this file.
1 /*
2 * @brief State Configurable Timer Blinky example
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #include <stdlib.h>
33 #include <string.h>
34 #include "board.h"
35 #include "sct_fsm.h"
36
65 /*****************************************************************************
66 * Private types/enumerations/variables
67 ****************************************************************************/
68
69 #ifdef BOARD_HITEX_EVA_18504350
70 #define MCSEL_BIT 23
71 #define MCSEL_PORT 6
72 #endif
73
74 /*****************************************************************************
75 * Public types/enumerations/variables
76 ****************************************************************************/
77
78 /*****************************************************************************
79 * Private functions
80 ****************************************************************************/
81
82 /* Initialise the SCT Pins */
83 void SCT_PinsConfigure(void)
84 {
85 #ifdef BOARD_HITEX_EVA_18504350
86 /* Enable signals on MC connector X19 */
87 Chip_SCU_PinMuxSet(0xD, 9, (SCU_MODE_MODE_INACT | SCU_MODE_FUNC4)); /* PD_9: GPIO 6.23, MCSEL */
88 Chip_GPIO_WriteDirBit(LPC_GPIO_PORT, MCSEL_PORT, MCSEL_BIT, true);
89 Chip_GPIO_WritePortBit(LPC_GPIO_PORT, MCSEL_PORT, MCSEL_BIT, false);
90
91 /* Pin configuration for SCT */
92 /* PD_10: SCTIN_1, used for DOWN input */
93 Chip_SCU_PinMuxSet(0xD, 10, (SCU_MODE_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC1));
94 /* PD_13: SCTIN_0 used for the RESET input */
95 Chip_SCU_PinMuxSet(0xD, 13, (SCU_MODE_MODE_REPEATER | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1));
96
97 Chip_SCU_PinMuxSet(0xE, 5, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC1)); /* PE_5: SCTOUT_3 connected to RGB red */
98 Chip_SCU_PinMuxSet(0xE, 6, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC1)); /* PE_6: SCTOUT_2 connected to RGB green */
99 Chip_SCU_PinMuxSet(0xE, 8, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC1)); /* P4_4: SCTOUT_4 connected to RGB blue */
100 Chip_SCU_PinMuxSet(0xE, 7, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC1)); /* P4_3: SCTOUT_5 */
101
102 /* Global configuration of the SCT */
103 Chip_SCT_Config(LPC_SCT, (SCT_CONFIG_16BIT_COUNTER ));
104
105 #elif defined(BOARD_KEIL_MCB_18574357)
106
107 /* Pin configuration for SCT */
108 /* P7_2: SCTIN_4 used for the DOWN input */
109 Chip_SCU_PinMuxSet(0x7, 2, (SCU_MODE_MODE_REPEATER | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1));
110 /* P7_3: SCTIN_3 used for the RESET input */
111 Chip_SCU_PinMuxSet(0x7, 3, (SCU_MODE_MODE_REPEATER | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1));
112
113 Chip_SCU_PinMuxSet(0xD, 11, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC6)); /* PD_11: SCTOUT_14 connected to LED1 */
114 Chip_SCU_PinMuxSet(0xD, 12, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC6)); /* PD_12: SCTOUT_10 connected to LED2 */
115 Chip_SCU_PinMuxSet(0xD, 13, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC6)); /* PD_13: SCTOUT_13 connected to LED3 */
116 Chip_SCU_PinMuxSet(0xD, 14, (SCU_MODE_MODE_PULLUP | SCU_MODE_FUNC6)); /* PD_14: SCTOUT_11 connected to LED4 */
117
118 /* Global configuration of the SCT */
119 Chip_SCT_Config(LPC_SCT, SCT_CONFIG_16BIT_COUNTER);
120
121 #else
122 #error Board not supported!
123 #endif
124
125 }
126
127 /*****************************************************************************
128 * Public functions
129 ****************************************************************************/
130
135 void SCT_IRQHandler(void)
136 {}
137
142 int main(void)
143 {
144 uint32_t SCT_FRQ;
145
146 /* Initialise Board */
147 Board_Init();
148
149 /* Initialize SCT */
150 Chip_SCT_Init(LPC_SCT);
151
152 /* Configure SCT pins */
153 SCT_PinsConfigure();
154
155 SCT_FRQ = Chip_Clock_GetRate(CLK_MX_SCT);
156 DEBUGOUT("SCT_FRQ: %d\r\n", SCT_FRQ);
157 Chip_SCT_ControlSetClr(LPC_SCT, SCT_CTRL_CLRCTR_L | SCT_CTRL_HALT_L | SCT_CTRL_PRE_L(256 - 1)
158 | SCT_CTRL_HALT_H | SCT_CTRL_CLRCTR_H | SCT_CTRL_PRE_H(256 - 1),
159 ENABLE);
160
161 /* Now use the FSM code to configure the state machine */
162 sct_fsm_init();
163
164 /* Start the SCT */
165 Chip_SCT_ControlSetClr(LPC_SCT, SCT_CTRL_STOP_L | SCT_CTRL_HALT_L | SCT_CTRL_STOP_H | SCT_CTRL_HALT_H, DISABLE);
166
167 while (1) {}
168 }
169