14
14
* limitations under the License.
15
15
*/
16
16
#include "gpio_api.h"
17
+ #include "mbed_error.h"
17
18
#include "pinmap.h"
18
19
#include <ti/devices/cc32xx/inc/hw_types.h>
19
20
#include <ti/devices/cc32xx/driverlib/pin.h>
20
21
#include <ti/devices/cc32xx/driverlib/gpio.h>
21
22
#include <ti/devices/cc32xx/inc/hw_ints.h>
22
23
#include <ti/devices/cc32xx/driverlib/prcm.h>
23
24
24
- #define PIN_RESERVED 0xFF
25
-
26
25
27
26
28
27
static const unsigned long g_ulPinToGPIOPinBit [64 ] =
@@ -79,17 +78,17 @@ static const PinMap PinMap_GPIO[] = {
79
78
80
79
{PIN_07 , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_16
81
80
{PIN_08 , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_17
82
- {PIN_RESERVED , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_18 (Reserved)
83
- {PIN_RESERVED , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_19 (Reserved)
84
- {PIN_RESERVED , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_20 (Reserved)
85
- {PIN_RESERVED , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_21 (Reserved)
81
+ // {PIN_RESERVED, CC3220SF_GPIOA2_BASE, 0}, //GPIO_18 (Reserved) No package pin associate with this GPIO
82
+ // {PIN_RESERVED, CC3220SF_GPIOA2_BASE, 0}, //GPIO_19 (Reserved) No package pin associate with this GPIO
83
+ // {PIN_RESERVED, CC3220SF_GPIOA2_BASE, 0}, //GPIO_20 (Reserved) No package pin associate with this GPIO
84
+ // {PIN_RESERVED, CC3220SF_GPIOA2_BASE, 0}, //GPIO_21 (Reserved) No package pin associate with this GPIO
86
85
{PIN_15 , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_22
87
86
{PIN_16 , CC3220SF_GPIOA2_BASE , 0 }, //GPIO_23
88
87
89
88
{PIN_17 , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_24
90
89
{PIN_21 , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_25
91
- {PIN_RESERVED , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_26 (Restricted Use; Antenna Selection 1 Only)
92
- {PIN_RESERVED , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_27 (Restricted Use; Antenna Selection 1 Only)
90
+ // {PIN_RESERVED, CC3220SF_GPIOA3_BASE, 0}, //GPIO_26 (Restricted Use; Antenna Selection 1 Only) No package pin associate with this GPIO
91
+ // {PIN_RESERVED, CC3220SF_GPIOA3_BASE, 0}, //GPIO_27 (Restricted Use; Antenna Selection 1 Only) No package pin associate with this GPIO
93
92
{PIN_18 , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_28
94
93
{PIN_20 , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_29
95
94
{PIN_53 , CC3220SF_GPIOA3_BASE , 0 }, //GPIO_30 (PM/Dig Mux)
@@ -108,6 +107,7 @@ uint32_t gpio_set(PinName pin)
108
107
// with the object created for the pin
109
108
void gpio_init (gpio_t * obj , PinName pin )
110
109
{
110
+ MBED_ASSERT (pin != (PinName )NC );
111
111
unsigned long gpio_base = (unsigned long )pinmap_peripheral (pin , PinMap_GPIO );
112
112
obj -> gpio_port_base_addr = gpio_base ;
113
113
obj -> pin = pin ;
@@ -151,11 +151,12 @@ void gpio_mode(gpio_t *obj, PinMode mode)
151
151
152
152
153
153
if (obj -> dir == PIN_INPUT ){ //setting the correct input pin mode from STD, PULL_UP, or PULL_DOWN
154
- PinModeSet (obj -> pin , inPinTypes [mode ]);
154
+ PinModeSet (obj -> pin , inPinTypes [mode ]);
155
+ pin_mode (obj -> pin , mode );
155
156
}
156
- else if (obj -> dir == PIN_OUTPUT ){ //setting the correct output pin mode from STD, open-drain PULL_UP, or open drain PULL_DOWN. It seem that Mbed does not have an option for open-drain no pull
157
+ else if (obj -> dir == PIN_OUTPUT ){ //setting the correct output pin mode from STD, open-drain PULL_UP, or open drain PULL_DOWN.
157
158
PinModeSet (obj -> pin , outPinTypes [mode ]);
158
- PinConfigSet (obj -> pin ,outPinStrengths [ 0 ], outPinTypes [ mode ] );
159
+ pin_mode (obj -> pin , mode );
159
160
}
160
161
161
162
}
@@ -168,16 +169,15 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
168
169
169
170
int gpio_is_connected (const gpio_t * obj )
170
171
{
171
- // TODO
172
- return 0 ;
172
+ return (obj -> pin == NC );
173
173
}
174
174
175
175
void gpio_write (gpio_t * obj , int value )
176
176
{
177
- GPIOPinWrite (obj -> gpio_port_base_addr , g_ulPinToGPIOPinBit [obj -> pin ], value << (g_ulPinToGPIOPinBit [obj -> pin ]>> 1 ));
177
+ GPIOPinWrite (obj -> gpio_port_base_addr , g_ulPinToGPIOPinBit [obj -> pin ], value * (g_ulPinToGPIOPinBit [obj -> pin ]));
178
178
}
179
179
180
180
int gpio_read (gpio_t * obj )
181
181
{
182
- return ( int ) GPIOPinRead (obj -> gpio_port_base_addr ,g_ulPinToGPIOPinBit [obj -> pin ]);
182
+ return ( GPIOPinRead (obj -> gpio_port_base_addr ,g_ulPinToGPIOPinBit [obj -> pin ]) != 0 );
183
183
}
0 commit comments