mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Fri Nov 09 11:33:53 2012 +0000
Revision:
8:c14af7958ef5
Child:
9:663789d7729f
SPI driver; ADC driver; DAC driver; microlib support; general bugfixing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 8:c14af7958ef5 1 /* mbed Microcontroller Library - gpio_object
emilmont 8:c14af7958ef5 2 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
emilmont 8:c14af7958ef5 3 */
emilmont 8:c14af7958ef5 4 #ifndef MBED_GPIO_OBJECT_H
emilmont 8:c14af7958ef5 5 #define MBED_GPIO_OBJECT_H
emilmont 8:c14af7958ef5 6
emilmont 8:c14af7958ef5 7 #ifdef __cplusplus
emilmont 8:c14af7958ef5 8 extern "C" {
emilmont 8:c14af7958ef5 9 #endif
emilmont 8:c14af7958ef5 10
emilmont 8:c14af7958ef5 11 typedef struct {
emilmont 8:c14af7958ef5 12 PinName pin;
emilmont 8:c14af7958ef5 13 uint32_t mask;
emilmont 8:c14af7958ef5 14
emilmont 8:c14af7958ef5 15 __IO uint32_t *reg_dir;
emilmont 8:c14af7958ef5 16 __IO uint32_t *reg_set;
emilmont 8:c14af7958ef5 17 __IO uint32_t *reg_clr;
emilmont 8:c14af7958ef5 18 __I uint32_t *reg_in;
emilmont 8:c14af7958ef5 19 } gpio_object;
emilmont 8:c14af7958ef5 20
emilmont 8:c14af7958ef5 21 static inline void gpio_write(gpio_object *obj, int value) {
emilmont 8:c14af7958ef5 22 if (value)
emilmont 8:c14af7958ef5 23 *obj->reg_set = obj->mask;
emilmont 8:c14af7958ef5 24 else
emilmont 8:c14af7958ef5 25 *obj->reg_clr = obj->mask;
emilmont 8:c14af7958ef5 26 }
emilmont 8:c14af7958ef5 27
emilmont 8:c14af7958ef5 28 static inline int gpio_read(gpio_object *obj) {
emilmont 8:c14af7958ef5 29 return ((*obj->reg_in & obj->mask) ? 1 : 0);
emilmont 8:c14af7958ef5 30 }
emilmont 8:c14af7958ef5 31
emilmont 8:c14af7958ef5 32 #ifdef __cplusplus
emilmont 8:c14af7958ef5 33 }
emilmont 8:c14af7958ef5 34 #endif
emilmont 8:c14af7958ef5 35
emilmont 8:c14af7958ef5 36 #endif