A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sat Apr 11 04:08:13 2015 +0000
Revision:
0:60d829a0353a
A simple 128x32 LCD program to quickstart with LCD on ARM mbed IoT Starter kit. Mbed Application Shield is required if using FRDM-K64F platform.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tushki7 0:60d829a0353a 1 /**************************************************************************//**
tushki7 0:60d829a0353a 2 * @file gic.h
tushki7 0:60d829a0353a 3 * @brief Implementation of GIC functions declared in CMSIS Cortex-A9 Core Peripheral Access Layer Header File
tushki7 0:60d829a0353a 4 * @version
tushki7 0:60d829a0353a 5 * @date 29 August 2013
tushki7 0:60d829a0353a 6 *
tushki7 0:60d829a0353a 7 * @note
tushki7 0:60d829a0353a 8 *
tushki7 0:60d829a0353a 9 ******************************************************************************/
tushki7 0:60d829a0353a 10 /* Copyright (c) 2011 - 2013 ARM LIMITED
tushki7 0:60d829a0353a 11
tushki7 0:60d829a0353a 12 All rights reserved.
tushki7 0:60d829a0353a 13 Redistribution and use in source and binary forms, with or without
tushki7 0:60d829a0353a 14 modification, are permitted provided that the following conditions are met:
tushki7 0:60d829a0353a 15 - Redistributions of source code must retain the above copyright
tushki7 0:60d829a0353a 16 notice, this list of conditions and the following disclaimer.
tushki7 0:60d829a0353a 17 - Redistributions in binary form must reproduce the above copyright
tushki7 0:60d829a0353a 18 notice, this list of conditions and the following disclaimer in the
tushki7 0:60d829a0353a 19 documentation and/or other materials provided with the distribution.
tushki7 0:60d829a0353a 20 - Neither the name of ARM nor the names of its contributors may be used
tushki7 0:60d829a0353a 21 to endorse or promote products derived from this software without
tushki7 0:60d829a0353a 22 specific prior written permission.
tushki7 0:60d829a0353a 23 *
tushki7 0:60d829a0353a 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
tushki7 0:60d829a0353a 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
tushki7 0:60d829a0353a 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
tushki7 0:60d829a0353a 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
tushki7 0:60d829a0353a 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
tushki7 0:60d829a0353a 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
tushki7 0:60d829a0353a 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
tushki7 0:60d829a0353a 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
tushki7 0:60d829a0353a 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
tushki7 0:60d829a0353a 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
tushki7 0:60d829a0353a 34 POSSIBILITY OF SUCH DAMAGE.
tushki7 0:60d829a0353a 35 ---------------------------------------------------------------------------*/
tushki7 0:60d829a0353a 36
tushki7 0:60d829a0353a 37 #ifndef GIC_H_
tushki7 0:60d829a0353a 38 #define GIC_H_
tushki7 0:60d829a0353a 39
tushki7 0:60d829a0353a 40 /* IO definitions (access restrictions to peripheral registers) */
tushki7 0:60d829a0353a 41 /**
tushki7 0:60d829a0353a 42 */
tushki7 0:60d829a0353a 43 #ifdef __cplusplus
tushki7 0:60d829a0353a 44 #define __I volatile /*!< Defines 'read only' permissions */
tushki7 0:60d829a0353a 45 #else
tushki7 0:60d829a0353a 46 #define __I volatile const /*!< Defines 'read only' permissions */
tushki7 0:60d829a0353a 47 #endif
tushki7 0:60d829a0353a 48 #define __O volatile /*!< Defines 'write only' permissions */
tushki7 0:60d829a0353a 49 #define __IO volatile /*!< Defines 'read / write' permissions */
tushki7 0:60d829a0353a 50
tushki7 0:60d829a0353a 51 /** \brief Structure type to access the Generic Interrupt Controller Distributor (GICD)
tushki7 0:60d829a0353a 52 */
tushki7 0:60d829a0353a 53 typedef struct
tushki7 0:60d829a0353a 54 {
tushki7 0:60d829a0353a 55 __IO uint32_t ICDDCR;
tushki7 0:60d829a0353a 56 __I uint32_t ICDICTR;
tushki7 0:60d829a0353a 57 __I uint32_t ICDIIDR;
tushki7 0:60d829a0353a 58 uint32_t RESERVED0[29];
tushki7 0:60d829a0353a 59 __IO uint32_t ICDISR[32];
tushki7 0:60d829a0353a 60 __IO uint32_t ICDISER[32];
tushki7 0:60d829a0353a 61 __IO uint32_t ICDICER[32];
tushki7 0:60d829a0353a 62 __IO uint32_t ICDISPR[32];
tushki7 0:60d829a0353a 63 __IO uint32_t ICDICPR[32];
tushki7 0:60d829a0353a 64 __I uint32_t ICDABR[32];
tushki7 0:60d829a0353a 65 uint32_t RESERVED1[32];
tushki7 0:60d829a0353a 66 __IO uint32_t ICDIPR[256];
tushki7 0:60d829a0353a 67 __IO uint32_t ICDIPTR[256];
tushki7 0:60d829a0353a 68 __IO uint32_t ICDICFR[64];
tushki7 0:60d829a0353a 69 uint32_t RESERVED2[128];
tushki7 0:60d829a0353a 70 __IO uint32_t ICDSGIR;
tushki7 0:60d829a0353a 71 } GICDistributor_Type;
tushki7 0:60d829a0353a 72
tushki7 0:60d829a0353a 73 /** \brief Structure type to access the Controller Interface (GICC)
tushki7 0:60d829a0353a 74 */
tushki7 0:60d829a0353a 75 typedef struct
tushki7 0:60d829a0353a 76 {
tushki7 0:60d829a0353a 77 __IO uint32_t ICCICR; // +0x000 - RW - CPU Interface Control Register
tushki7 0:60d829a0353a 78 __IO uint32_t ICCPMR; // +0x004 - RW - Interrupt Priority Mask Register
tushki7 0:60d829a0353a 79 __IO uint32_t ICCBPR; // +0x008 - RW - Binary Point Register
tushki7 0:60d829a0353a 80 __I uint32_t ICCIAR; // +0x00C - RO - Interrupt Acknowledge Register
tushki7 0:60d829a0353a 81 __IO uint32_t ICCEOIR; // +0x010 - WO - End of Interrupt Register
tushki7 0:60d829a0353a 82 __I uint32_t ICCRPR; // +0x014 - RO - Running Priority Register
tushki7 0:60d829a0353a 83 __I uint32_t ICCHPIR; // +0x018 - RO - Highest Pending Interrupt Register
tushki7 0:60d829a0353a 84 __IO uint32_t ICCABPR; // +0x01C - RW - Aliased Binary Point Register
tushki7 0:60d829a0353a 85
tushki7 0:60d829a0353a 86 uint32_t RESERVED[55];
tushki7 0:60d829a0353a 87
tushki7 0:60d829a0353a 88 __I uint32_t ICCIIDR; // +0x0FC - RO - CPU Interface Identification Register
tushki7 0:60d829a0353a 89 } GICInterface_Type;
tushki7 0:60d829a0353a 90
tushki7 0:60d829a0353a 91 /*@} end of GICD */
tushki7 0:60d829a0353a 92
tushki7 0:60d829a0353a 93 /* ########################## GIC functions #################################### */
tushki7 0:60d829a0353a 94 /** \brief Functions that manage interrupts via the GIC.
tushki7 0:60d829a0353a 95 @{
tushki7 0:60d829a0353a 96 */
tushki7 0:60d829a0353a 97
tushki7 0:60d829a0353a 98 /** \brief Enable DistributorGICInterface->ICCICR |= 1; //enable interface
tushki7 0:60d829a0353a 99
tushki7 0:60d829a0353a 100 Enables the forwarding of pending interrupts to the CPU interfaces.
tushki7 0:60d829a0353a 101
tushki7 0:60d829a0353a 102 */
tushki7 0:60d829a0353a 103 void GIC_EnableDistributor(void);
tushki7 0:60d829a0353a 104
tushki7 0:60d829a0353a 105 /** \brief Disable Distributor
tushki7 0:60d829a0353a 106
tushki7 0:60d829a0353a 107 Disables the forwarding of pending interrupts to the CPU interfaces.
tushki7 0:60d829a0353a 108
tushki7 0:60d829a0353a 109 */
tushki7 0:60d829a0353a 110 void GIC_DisableDistributor(void);
tushki7 0:60d829a0353a 111
tushki7 0:60d829a0353a 112 /** \brief Provides information about the configuration of the GIC.
tushki7 0:60d829a0353a 113 Provides information about the configuration of the GIC.
tushki7 0:60d829a0353a 114 - whether the GIC implements the Security Extensions
tushki7 0:60d829a0353a 115 - the maximum number of interrupt IDs that the GIC supports
tushki7 0:60d829a0353a 116 - the number of CPU interfaces implemented
tushki7 0:60d829a0353a 117 - if the GIC implements the Security Extensions, the maximum number of implemented Lockable Shared Peripheral Interrupts (LSPIs).
tushki7 0:60d829a0353a 118
tushki7 0:60d829a0353a 119 \return Distributor Information.
tushki7 0:60d829a0353a 120 */
tushki7 0:60d829a0353a 121 uint32_t GIC_DistributorInfo(void);
tushki7 0:60d829a0353a 122
tushki7 0:60d829a0353a 123 /** \brief Distributor Implementer Identification Register.
tushki7 0:60d829a0353a 124
tushki7 0:60d829a0353a 125 Distributor Implementer Identification Register
tushki7 0:60d829a0353a 126
tushki7 0:60d829a0353a 127 \return Implementer Information.
tushki7 0:60d829a0353a 128 */
tushki7 0:60d829a0353a 129 uint32_t GIC_DistributorImplementer(void);
tushki7 0:60d829a0353a 130
tushki7 0:60d829a0353a 131 /** \brief Set list of processors that the interrupt is sent to if it is asserted.
tushki7 0:60d829a0353a 132
tushki7 0:60d829a0353a 133 The ICDIPTRs provide an 8-bit CPU targets field for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 134 This field stores the list of processors that the interrupt is sent to if it is asserted.
tushki7 0:60d829a0353a 135
tushki7 0:60d829a0353a 136 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 137 \param [in] target CPU target
tushki7 0:60d829a0353a 138 */
tushki7 0:60d829a0353a 139 void GIC_SetTarget(IRQn_Type IRQn, uint32_t cpu_target);
tushki7 0:60d829a0353a 140
tushki7 0:60d829a0353a 141 /** \brief Get list of processors that the interrupt is sent to if it is asserted.
tushki7 0:60d829a0353a 142
tushki7 0:60d829a0353a 143 The ICDIPTRs provide an 8-bit CPU targets field for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 144 This field stores the list of processors that the interrupt is sent to if it is asserted.
tushki7 0:60d829a0353a 145
tushki7 0:60d829a0353a 146 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 147 \param [in] target CPU target
tushki7 0:60d829a0353a 148 */
tushki7 0:60d829a0353a 149 uint32_t GIC_GetTarget(IRQn_Type IRQn);
tushki7 0:60d829a0353a 150
tushki7 0:60d829a0353a 151 /** \brief Enable Interface
tushki7 0:60d829a0353a 152
tushki7 0:60d829a0353a 153 Enables the signalling of interrupts to the target processors.
tushki7 0:60d829a0353a 154
tushki7 0:60d829a0353a 155 */
tushki7 0:60d829a0353a 156 void GIC_EnableInterface(void);
tushki7 0:60d829a0353a 157
tushki7 0:60d829a0353a 158 /** \brief Disable Interface
tushki7 0:60d829a0353a 159
tushki7 0:60d829a0353a 160 Disables the signalling of interrupts to the target processors.
tushki7 0:60d829a0353a 161
tushki7 0:60d829a0353a 162 */
tushki7 0:60d829a0353a 163 void GIC_DisableInterface(void);
tushki7 0:60d829a0353a 164
tushki7 0:60d829a0353a 165 /** \brief Acknowledge Interrupt
tushki7 0:60d829a0353a 166
tushki7 0:60d829a0353a 167 The function acknowledges the highest priority pending interrupt and returns its IRQ number.
tushki7 0:60d829a0353a 168
tushki7 0:60d829a0353a 169 \return Interrupt number
tushki7 0:60d829a0353a 170 */
tushki7 0:60d829a0353a 171 IRQn_Type GIC_AcknowledgePending(void);
tushki7 0:60d829a0353a 172
tushki7 0:60d829a0353a 173 /** \brief End Interrupt
tushki7 0:60d829a0353a 174
tushki7 0:60d829a0353a 175 The function writes the end of interrupt register, indicating that handling of the interrupt is complete.
tushki7 0:60d829a0353a 176
tushki7 0:60d829a0353a 177 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 178 */
tushki7 0:60d829a0353a 179 void GIC_EndInterrupt(IRQn_Type IRQn);
tushki7 0:60d829a0353a 180
tushki7 0:60d829a0353a 181
tushki7 0:60d829a0353a 182 /** \brief Enable Interrupt
tushki7 0:60d829a0353a 183
tushki7 0:60d829a0353a 184 Set-enable bit for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 185
tushki7 0:60d829a0353a 186 \param [in] IRQn External interrupt number.
tushki7 0:60d829a0353a 187 */
tushki7 0:60d829a0353a 188 void GIC_EnableIRQ(IRQn_Type IRQn);
tushki7 0:60d829a0353a 189
tushki7 0:60d829a0353a 190 /** \brief Disable Interrupt
tushki7 0:60d829a0353a 191
tushki7 0:60d829a0353a 192 Clear-enable bit for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 193
tushki7 0:60d829a0353a 194 \param [in] IRQn Number of the external interrupt to disable
tushki7 0:60d829a0353a 195 */
tushki7 0:60d829a0353a 196 void GIC_DisableIRQ(IRQn_Type IRQn);
tushki7 0:60d829a0353a 197
tushki7 0:60d829a0353a 198 /** \brief Set Pending Interrupt
tushki7 0:60d829a0353a 199
tushki7 0:60d829a0353a 200 Set-pending bit for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 201
tushki7 0:60d829a0353a 202 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 203 */
tushki7 0:60d829a0353a 204 void GIC_SetPendingIRQ(IRQn_Type IRQn);
tushki7 0:60d829a0353a 205
tushki7 0:60d829a0353a 206 /** \brief Clear Pending Interrupt
tushki7 0:60d829a0353a 207
tushki7 0:60d829a0353a 208 Clear-pending bit for each interrupt supported by the GIC
tushki7 0:60d829a0353a 209
tushki7 0:60d829a0353a 210 \param [in] IRQn Number of the interrupt for clear pending
tushki7 0:60d829a0353a 211 */
tushki7 0:60d829a0353a 212 void GIC_ClearPendingIRQ(IRQn_Type IRQn);
tushki7 0:60d829a0353a 213
tushki7 0:60d829a0353a 214 /** \brief Int_config field for each interrupt supported by the GIC.
tushki7 0:60d829a0353a 215
tushki7 0:60d829a0353a 216 This field identifies whether the corresponding interrupt is:
tushki7 0:60d829a0353a 217 (1) edge-triggered or (0) level-sensitive
tushki7 0:60d829a0353a 218 (1) 1-N model or (0) N-N model
tushki7 0:60d829a0353a 219
tushki7 0:60d829a0353a 220 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 221 \param [in] edge_level (1) edge-triggered or (0) level-sensitive
tushki7 0:60d829a0353a 222 \param [in] model (1) 1-N model or (0) N-N model
tushki7 0:60d829a0353a 223 */
tushki7 0:60d829a0353a 224 void GIC_SetLevelModel(IRQn_Type IRQn, int8_t edge_level, int8_t model);
tushki7 0:60d829a0353a 225
tushki7 0:60d829a0353a 226
tushki7 0:60d829a0353a 227 /** \brief Set Interrupt Priority
tushki7 0:60d829a0353a 228
tushki7 0:60d829a0353a 229 The function sets the priority of an interrupt.
tushki7 0:60d829a0353a 230
tushki7 0:60d829a0353a 231 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 232 \param [in] priority Priority to set.
tushki7 0:60d829a0353a 233 */
tushki7 0:60d829a0353a 234 void GIC_SetPriority(IRQn_Type IRQn, uint32_t priority);
tushki7 0:60d829a0353a 235
tushki7 0:60d829a0353a 236 /** \brief Get Interrupt Priority
tushki7 0:60d829a0353a 237
tushki7 0:60d829a0353a 238 The function reads the priority of an interrupt.
tushki7 0:60d829a0353a 239
tushki7 0:60d829a0353a 240 \param [in] IRQn Interrupt number.
tushki7 0:60d829a0353a 241 \return Interrupt Priority.
tushki7 0:60d829a0353a 242 */
tushki7 0:60d829a0353a 243 uint32_t GIC_GetPriority(IRQn_Type IRQn);
tushki7 0:60d829a0353a 244
tushki7 0:60d829a0353a 245 /** \brief CPU Interface Priority Mask Register
tushki7 0:60d829a0353a 246
tushki7 0:60d829a0353a 247 The priority mask level for the CPU interface. If the priority of an interrupt is higher than the
tushki7 0:60d829a0353a 248 value indicated by this field, the interface signals the interrupt to the processor.
tushki7 0:60d829a0353a 249
tushki7 0:60d829a0353a 250 \param [in] Mask.
tushki7 0:60d829a0353a 251 */
tushki7 0:60d829a0353a 252 void GIC_InterfacePriorityMask(uint32_t priority);
tushki7 0:60d829a0353a 253
tushki7 0:60d829a0353a 254 /** \brief Set the binary point.
tushki7 0:60d829a0353a 255
tushki7 0:60d829a0353a 256 Set the point at which the priority value fields split into two parts, the group priority field and the subpriority field.
tushki7 0:60d829a0353a 257
tushki7 0:60d829a0353a 258 \param [in] Mask.
tushki7 0:60d829a0353a 259 */
tushki7 0:60d829a0353a 260 void GIC_SetBinaryPoint(uint32_t binary_point);
tushki7 0:60d829a0353a 261
tushki7 0:60d829a0353a 262 /** \brief Get the binary point.
tushki7 0:60d829a0353a 263
tushki7 0:60d829a0353a 264 Get the point at which the priority value fields split into two parts, the group priority field and the subpriority field.
tushki7 0:60d829a0353a 265
tushki7 0:60d829a0353a 266 \return Binary point.
tushki7 0:60d829a0353a 267 */
tushki7 0:60d829a0353a 268 uint32_t GIC_GetBinaryPoint(uint32_t binary_point);
tushki7 0:60d829a0353a 269
tushki7 0:60d829a0353a 270 /** \brief Get Interrupt state.
tushki7 0:60d829a0353a 271
tushki7 0:60d829a0353a 272 Get the interrupt state, whether pending and/or active
tushki7 0:60d829a0353a 273
tushki7 0:60d829a0353a 274 \return 0 - inactive, 1 - pending, 2 - active, 3 - pending and active
tushki7 0:60d829a0353a 275 */
tushki7 0:60d829a0353a 276 uint32_t GIC_GetIRQStatus(IRQn_Type IRQn);
tushki7 0:60d829a0353a 277
tushki7 0:60d829a0353a 278 /** \brief Send Software Generated interrupt
tushki7 0:60d829a0353a 279
tushki7 0:60d829a0353a 280 Provides an interrupt priority filter. Only interrupts with higher priority than the value in this register can be signalled to the processor.
tushki7 0:60d829a0353a 281 GIC_InterfacePriorityMask
tushki7 0:60d829a0353a 282 \param [in] IRQn The Interrupt ID of the SGI.
tushki7 0:60d829a0353a 283 \param [in] target_list CPUTargetList
tushki7 0:60d829a0353a 284 \param [in] filter_list TargetListFilter
tushki7 0:60d829a0353a 285 */
tushki7 0:60d829a0353a 286 void GIC_SendSGI(IRQn_Type IRQn, uint32_t target_list, uint32_t filter_list);
tushki7 0:60d829a0353a 287
tushki7 0:60d829a0353a 288 /** \brief API call to initialise the interrupt distributor
tushki7 0:60d829a0353a 289
tushki7 0:60d829a0353a 290 API call to initialise the interrupt distributor
tushki7 0:60d829a0353a 291
tushki7 0:60d829a0353a 292 */
tushki7 0:60d829a0353a 293 void GIC_DistInit(void);
tushki7 0:60d829a0353a 294
tushki7 0:60d829a0353a 295 /** \brief API call to initialise the CPU interface
tushki7 0:60d829a0353a 296
tushki7 0:60d829a0353a 297 API call to initialise the CPU interface
tushki7 0:60d829a0353a 298
tushki7 0:60d829a0353a 299 */
tushki7 0:60d829a0353a 300 void GIC_CPUInterfaceInit(void);
tushki7 0:60d829a0353a 301
tushki7 0:60d829a0353a 302 /** \brief API call to set the Interrupt Configuration Registers
tushki7 0:60d829a0353a 303
tushki7 0:60d829a0353a 304 API call to initialise the Interrupt Configuration Registers
tushki7 0:60d829a0353a 305
tushki7 0:60d829a0353a 306 */
tushki7 0:60d829a0353a 307 void GIC_SetICDICFR (const uint32_t *ICDICFRn);
tushki7 0:60d829a0353a 308
tushki7 0:60d829a0353a 309 /** \brief API call to Enable the GIC
tushki7 0:60d829a0353a 310
tushki7 0:60d829a0353a 311 API call to Enable the GIC
tushki7 0:60d829a0353a 312
tushki7 0:60d829a0353a 313 */
tushki7 0:60d829a0353a 314 void GIC_Enable(void);
tushki7 0:60d829a0353a 315
tushki7 0:60d829a0353a 316 #endif /* GIC_H_ */