1 /*! 2 * ======== GPIO ======== 3 * MSP430 General Purpose Input Output Ports 4 */ 5 metaonly interface IGPIO inherits xdc.platform.IPeripheral { 6 7 /*! GPIO Bit 0 Definitions */ 8 enum Bit0_t { 9 BIT0_OFF = 0x00u, 10 BIT0 = 0x01u 11 }; 12 13 enum Bit1_t { 14 BIT1_OFF = 0x00u, 15 BIT1 = 0x02u 16 }; 17 18 enum Bit2_t { 19 BIT2_OFF = 0x00u, 20 BIT2 = 0x04u 21 }; 22 23 enum Bit3_t { 24 BIT3_OFF = 0x00u, 25 BIT3 = 0x08u 26 }; 27 28 enum Bit4_t { 29 BIT4_OFF = 0x00u, 30 BIT4 = 0x10u 31 }; 32 33 enum Bit5_t { 34 BIT5_OFF = 0x00u, 35 BIT5 = 0x20u 36 }; 37 38 enum Bit6_t { 39 BIT6_OFF = 0x00u, 40 BIT6 = 0x20u 41 }; 42 43 enum Bit7_t { 44 BIT7_OFF = 0x00u, 45 BIT7 = 0x80u 46 }; 47 48 /*! 49 * ======== GpioBits8_t ======== 50 * Generic GPIO 8-bit Register 51 * 52 * @see #GpioBits8_t 53 */ 54 struct GpioBits8PxIn_t { 55 Bit0_t Bit0; /*! GPIO Input Signal Bit 0 */ 56 Bit1_t Bit1; /*! GPIO Input Signal Bit 1 */ 57 Bit2_t Bit2; /*! GPIO Input Signal Bit 2 */ 58 Bit3_t Bit3; /*! GPIO Input Signal Bit 3 */ 59 Bit4_t Bit4; /*! GPIO Input Signal Bit 4 */ 60 Bit5_t Bit5; /*! GPIO Input Signal Bit 5 */ 61 Bit6_t Bit6; /*! GPIO Input Signal Bit 6 */ 62 Bit7_t Bit7; /*! GPIO Input Signal Bit 7 */ 63 } 64 65 /*! 66 * ======== GpioBits8PxOut_t ======== 67 * Generic GPIO 8-bit PxOUT Register 68 * 69 * @see #GpioBits8PxOut_t 70 */ 71 struct GpioBits8PxOut_t { 72 Bit0_t Bit0; /*! GPIO Output Signal Bit 0 */ 73 Bit1_t Bit1; /*! GPIO Output Signal Bit 1 */ 74 Bit2_t Bit2; /*! GPIO Output Signal Bit 2 */ 75 Bit3_t Bit3; /*! GPIO Output Signal Bit 3 */ 76 Bit4_t Bit4; /*! GPIO Output Signal Bit 4 */ 77 Bit5_t Bit5; /*! GPIO Output Signal Bit 5 */ 78 Bit6_t Bit6; /*! GPIO Output Signal Bit 6 */ 79 Bit7_t Bit7; /*! GPIO Output Signal Bit 7 */ 80 } 81 82 /*! 83 * ======== GpioBits8PxDir_t ======== 84 * Generic GPIO 8-bit PxDIR Register 85 * 86 * @see #GpioBits8PxDir_t 87 */ 88 struct GpioBits8PxDir_t { 89 Bit0_t Bit0; /*! GPIO Select Direction Bit 0 90 * Bit = 0: The port pin is switched to input direction 91 * Bit = 1: The port pin is switched to output direction */ 92 Bit1_t Bit1; /*! GPIO Select Direction Bit 1 93 * Bit = 0: The port pin is switched to input direction 94 * Bit = 1: The port pin is switched to output direction */ 95 Bit2_t Bit2; /*! GPIO Select Direction Bit 2 96 * Bit = 0: The port pin is switched to input direction 97 * Bit = 1: The port pin is switched to output direction */ 98 Bit3_t Bit3; /*! GPIO Select Direction Bit 3 99 * Bit = 0: The port pin is switched to input direction 100 * Bit = 1: The port pin is switched to output direction */ 101 Bit4_t Bit4; /*! GPIO Select Direction Bit 4 102 * Bit = 0: The port pin is switched to input direction 103 * Bit = 1: The port pin is switched to output direction */ 104 Bit5_t Bit5; /*! GPIO Select Direction Bit 5 105 * Bit = 0: The port pin is switched to input direction 106 * Bit = 1: The port pin is switched to output direction */ 107 Bit6_t Bit6; /*! GPIO Select Direction Bit 6 108 * Bit = 0: The port pin is switched to input direction 109 * Bit = 1: The port pin is switched to output direction */ 110 Bit7_t Bit7; /*! GPIO Select Direction Bit 7 111 * Bit = 0: The port pin is switched to input direction 112 * Bit = 1: The port pin is switched to output direction */ 113 } 114 115 /*! 116 * ======== GpioBits8PxRen_t ======== 117 * Generic GPIO 8-bit PxREN Register 118 * 119 * @see #GpioBits8PxRen_t 120 */ 121 struct GpioBits8PxRen_t { 122 Bit0_t Bit0; /*! GPIO Enables or Disables Pullup/Pulldown Bit 0 123 * Bit = 0: Pullup/pulldown resistor disabled 124 * Bit = 1: Pullup/pulldown resistor enabled 125 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 126 Bit1_t Bit1; /*! GPIO Enables or Disables Pullup/Pulldown Bit 1 127 * Bit = 0: Pullup/pulldown resistor disabled 128 * Bit = 1: Pullup/pulldown resistor enabled 129 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 130 Bit2_t Bit2; /*! GPIO Enables or Disables Pullup/Pulldown Bit 2 131 * Bit = 0: Pullup/pulldown resistor disabled 132 * Bit = 1: Pullup/pulldown resistor enabled 133 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 134 Bit3_t Bit3; /*! GPIO Enables or Disables Pullup/Pulldown Bit 3 135 * Bit = 0: Pullup/pulldown resistor disabled 136 * Bit = 1: Pullup/pulldown resistor enabled 137 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 138 Bit4_t Bit4; /*! GPIO Enables or Disables Pullup/Pulldown Bit 4 139 * Bit = 0: Pullup/pulldown resistor disabled 140 * Bit = 1: Pullup/pulldown resistor enabled 141 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 142 Bit5_t Bit5; /*! GPIO Enables or Disables Pullup/Pulldown Bit 5 143 * Bit = 0: Pullup/pulldown resistor disabled 144 * Bit = 1: Pullup/pulldown resistor enabled 145 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 146 Bit6_t Bit6; /*! GPIO Enables or Disables Pullup/Pulldown Bit 6 147 * Bit = 0: Pullup/pulldown resistor disabled 148 * Bit = 1: Pullup/pulldown resistor enabled 149 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 150 Bit7_t Bit7; /*! GPIO Enables or Disables Pullup/Pulldown Bit 7 151 * Bit = 0: Pullup/pulldown resistor disabled 152 * Bit = 1: Pullup/pulldown resistor enabled 153 * Set Pullup/down via PxOUT 0 = Down; 1 = Up */ 154 } 155 156 /*! 157 * ======== GpioBits8PxSel_t ======== 158 * Generic GPIO 8-bit PxSEL Register 159 * 160 * @see #GpioBits8PxSel_t 161 */ 162 struct GpioBits8PxSel_t { 163 Bit0_t Bit0; /*! GPIO Select Pin Function Bit 0 164 *See the device-specific data sheet to determine pin functions. */ 165 Bit1_t Bit1; /*! GPIO Select Pin Function Bit 1 166 *See the device-specific data sheet to determine pin functions. */ 167 Bit2_t Bit2; /*! GPIO Select Pin Function Bit 2 168 *See the device-specific data sheet to determine pin functions. */ 169 Bit3_t Bit3; /*! GPIO Select Pin Function Bit 3 170 *See the device-specific data sheet to determine pin functions. */ 171 Bit4_t Bit4; /*! GPIO Select Pin Function Bit 4 172 *See the device-specific data sheet to determine pin functions. */ 173 Bit5_t Bit5; /*! GPIO Select Pin Function Bit 5 174 *See the device-specific data sheet to determine pin functions. */ 175 Bit6_t Bit6; /*! GPIO Select Pin Function Bit 6 176 *See the device-specific data sheet to determine pin functions. */ 177 Bit7_t Bit7; /*! GPIO Select Pin Function Bit 7 178 *See the device-specific data sheet to determine pin functions. */ 179 } 180 181 /*! 182 * ======== GpioBits8PxIe_t ======== 183 * Generic GPIO 8-bit PxIE Register 184 * 185 * @see #GpioBits8PxIe_t 186 */ 187 struct GpioBits8PxIe_t { 188 Bit0_t Bit0; /*! GPIO Interrupt Enable Bit 0 189 * Bit = 0: The interrupt is disabled. 190 * Bit = 1: The interrupt is enabled. */ 191 Bit1_t Bit1; /*! GPIO Interrupt Enable Bit 1 192 * Bit = 0: The interrupt is disabled. 193 * Bit = 1: The interrupt is enabled. */ 194 Bit2_t Bit2; /*! GPIO Interrupt Enable Bit 2 195 * Bit = 0: The interrupt is disabled. 196 * Bit = 1: The interrupt is enabled. */ 197 Bit3_t Bit3; /*! GPIO Interrupt Enable Bit 3 198 * Bit = 0: The interrupt is disabled. 199 * Bit = 1: The interrupt is enabled. */ 200 Bit4_t Bit4; /*! GPIO Interrupt Enable Bit 4 201 * Bit = 0: The interrupt is disabled. 202 * Bit = 1: The interrupt is enabled. */ 203 Bit5_t Bit5; /*! GPIO Interrupt Enable Bit 5 204 * Bit = 0: The interrupt is disabled. 205 * Bit = 1: The interrupt is enabled. */ 206 Bit6_t Bit6; /*! GPIO Interrupt Enable Bit 6 207 * Bit = 0: The interrupt is disabled. 208 * Bit = 1: The interrupt is enabled. */ 209 Bit7_t Bit7; /*! GPIO Interrupt Enable Bit 7 210 * Bit = 0: The interrupt is disabled. 211 * Bit = 1: The interrupt is enabled. */ 212 } 213 214 /*! 215 * ======== GpioBits8PxIes_t ======== 216 * Generic GPIO 8-bit PxIES Register 217 * 218 * @see #GpioBits8PxIes_t 219 */ 220 struct GpioBits8PxIes_t { 221 Bit0_t Bit0; /*! GPIO Select Interrupt Edge Bit 0 222 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 223 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 224 Bit1_t Bit1; /*! GPIO Select Interrupt Edge Bit 1 225 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 226 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 227 Bit2_t Bit2; /*! GPIO Select Interrupt Edge Bit 2 228 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 229 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 230 Bit3_t Bit3; /*! GPIO Select Interrupt Edge Bit 3 231 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 232 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 233 Bit4_t Bit4; /*! GPIO Select Interrupt Edge Bit 4 234 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 235 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 236 Bit5_t Bit5; /*! GPIO Select Interrupt Edge Bit 5 237 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 238 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 239 Bit6_t Bit6; /*! GPIO Select Interrupt Edge Bit 6 240 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 241 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 242 Bit7_t Bit7; /*! GPIO Select Interrupt Edge Bit 7 243 * Bit = 0: The PxIFGx flag is set with a low-to-high transition 244 * Bit = 1: The PxIFGx flag is set with a high-to-low transition */ 245 } 246 247 /*! 248 * ======== GpioBits8PxIfg_t ======== 249 * Generic GPIO 8-bit PxIFG Register 250 * 251 * @see #GpioBits8PxIfg_t 252 */ 253 struct GpioBits8PxIfg_t { 254 Bit0_t Bit0; /*! GPIO Interrupt Flag Bit 0 255 * Bit = 0: No interrupt is pending 256 * Bit = 1: An interrupt is pending */ 257 Bit1_t Bit1; /*! GPIO Interrupt Flag Bit 1 258 * Bit = 0: No interrupt is pending 259 * Bit = 1: An interrupt is pending */ 260 Bit2_t Bit2; /*! GPIO Interrupt Flag Bit 2 261 * Bit = 0: No interrupt is pending 262 * Bit = 1: An interrupt is pending */ 263 Bit3_t Bit3; /*! GPIO Interrupt Flag Bit 3 264 * Bit = 0: No interrupt is pending 265 * Bit = 1: An interrupt is pending */ 266 Bit4_t Bit4; /*! GPIO Interrupt Flag Bit 4 267 * Bit = 0: No interrupt is pending 268 * Bit = 1: An interrupt is pending */ 269 Bit5_t Bit5; /*! GPIO Interrupt Flag Bit 5 270 * Bit = 0: No interrupt is pending 271 * Bit = 1: An interrupt is pending */ 272 Bit6_t Bit6; /*! GPIO Interrupt Flag Bit 6 273 * Bit = 0: No interrupt is pending 274 * Bit = 1: An interrupt is pending */ 275 Bit7_t Bit7; /*! GPIO Interrupt Flag Bit 7 276 * Bit = 0: No interrupt is pending 277 * Bit = 1: An interrupt is pending */ 278 } 279 280 /*! 281 * ======== DeviceRegisterConfig_t ======== 282 * Device Register Configuration Descriptor 283 * 284 * Type to describe how a register is configured for a particular 285 * use. The type allows setting and clearing of an arbitrary bit 286 * pattern inside the specified register. 287 * 288 * @see #DeviceRegisterConfig_t 289 */ 290 struct DeviceRegisterConfig_t { 291 String register; 292 UInt bitSetMask; 293 UInt bitClearMask; 294 } 295 296 /*! 297 * ======== DevicePinFunction_t ======== 298 * Device Pin Functional Descriptor 299 * 300 * Type to describe how a device pin is configured for all its 301 * different uses that are possible. The function names are consolidated 302 * in one String array rather than located together with the function- 303 * specific data to allow easier access by Grace widgets. The functionConfig 304 * member contains an arbitrary-length array describing all register 305 * settings that need to be performed to configure a certain function. 306 * 307 * @see #DevicePinFunction_t 308 */ 309 struct DevicePinFunction_t { 310 String functionName[]; 311 DeviceRegisterConfig_t functionConfig[][]; 312 } 313 314 /*! 315 * ======== DevicePin_t ======== 316 * Device Pin Descriptor 317 * 318 * Type to describe a single device pin and all its possible 319 * configurations. 320 * 321 * @see #DevicePin_t 322 */ 323 struct DevicePin_t { 324 String pinName; 325 DevicePinFunction_t pinFunction; 326 } 327 328 /*! 329 * ======== MatchedPortFunction_t ======== 330 * Port Function Enumeration Type 331 * 332 * This type is used to store a list of applicable pins based on the 333 * search criteria when using the function findPinsForFunction(). 334 * 335 * @see #MatchedPortFunction_t 336 */ 337 struct MatchedPortFunction_t { 338 UInt port[]; 339 UInt pin[]; 340 String pinName[]; 341 UInt functionIndex[]; 342 String functionName[]; 343 } 344 345 /*! 346 * ======== DevicePinFunctionSetting_t ======== 347 * Device Pin Functional Setting Descriptor 348 * 349 * Type to store the selected pin configuration and a reference 350 * to the object that last modified the configuration. 351 * 352 * @see #DevicePinFunctionSetting_t 353 */ 354 struct DevicePinFunctionSetting_t { 355 UInt functionIndex; 356 Any owner; 357 } 358 359 /*! 360 * ======== ForceSetDefaultRegister_t ======== 361 * Force Set Default Register 362 * 363 * Type to store if each register needs to be forced initialized 364 * even if the register is in default state. 365 * 366 * @see #ForceSetDefaultRegister_t 367 */ 368 struct ForceSetDefaultRegister_t { 369 String register; 370 Bool regForceSet; 371 } 372 373 instance: 374 /*! Fordward Declaration of Device Pin Functional Configuration */ 375 config DevicePinFunctionSetting_t devicePinSetting[][]; 376 377 /*! 378 * ======== findPinsForFunction ======== 379 * Identify all device pins that can be used to serve a certain purpose 380 * 381 * Function to scan through the pin configuration database to identify 382 * a list of device pins matching a regular expression. 383 */ 384 MatchedPortFunction_t findPinsForFunction(String regExp); 385 386 /*! 387 * ======== pinFunctionIsActive ======== 388 * Check if a pin is enabled for a certain function 389 * 390 * This function is used to check if a certain functionality is enabled 391 * on a given device pins (returns 'true' in that case). 392 */ 393 Bool pinFunctionIsActive(UInt port, UInt pin, String regExp); 394 395 /*! 396 * ======== getPinFunctionIndex ======== 397 * Get a pin's current functional configuration 398 * 399 * This function is used to obtain the current configuration of a given 400 * device pin. The returned value can be used as an index to obtain further 401 * information from the pin configuration database. 402 */ 403 UInt getPinFunctionIndex(UInt port, UInt pin); 404 405 /*! 406 * ======== getPinOwner ======== 407 * This function returns the current owner of the specified device pin. 408 */ 409 Any getPinOwner(UInt port, UInt pin); 410 411 /*! 412 * ======== setPinFunctionUsingIndex ======== 413 * Configure a device pin to a specific peripheral function 414 * 415 * This function is used to configure a device pin to a specific peripheral 416 * function that is identified by an index. The index corresponds to an 417 * associated set of configuration parameters stored in the pin configuration 418 * database. The owner parameter can be used to protect a pin from being 419 * used by somebody else. A pin configuration can only be changed if the 420 * current owner is undefined, or of the current owner matches the 421 * owner specified as function parameter. 422 */ 423 Void setPinFunctionUsingIndex(UInt port, UInt pin, UInt index, Any owner); 424 425 /*! 426 * ======== setDefaultPinFunction ======== 427 * Configure a device pin to its default state 428 * 429 * This function is used to configure a device pin to its default state 430 * and is typically used when a peripheral module relinquishes ownership 431 * of a pin so that it can be used by other peripheral modules. 432 */ 433 Void setDefaultPinFunction(UInt port, UInt pin, Any owner); 434 }