Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
41
Ver.1.0.0
static
inline
unsigned
char
gpio_read
(
GPIO_PinTypeDef
pin)
;
Note: If GPIO input is low level, 0 is returned; if GPIO input is high level, non-zero
value (
may not be 1
) is returned.
In firmware, it
’s recommended to invert the read values rather than using the format
such as “if( gpio_read(GPIO_PA0) == 1)”. Inverted values will be either 1 or 0.
if( !gpio_read(GPIO_PA0) ) // judge high/low level
4. oe: Output enable
static
inline
void
gpio_set_output_en
(
GPIO_PinTypeDef
pin,
unsigned
int
value)
Value: 1-enable, 0-disable
5. dataO: Data output. Value
: When output is enabled, “1” indicates high-level output,
while “0” indicates low-level output.
static
inline
void
gpio_write
(
GPIO_PinTypeDef
pin,
unsigned
int
value)
6. Configurations for internal analog pull-up/pull-down resistor: x1 pull-up, x10 pull-
down, x100 pull- up. The resistance range for x1 is 8Kohm~60Kohm; x10
80Kohm~600Kohm; x100 500Kohm~2Mohm.
void
gpio_setup_up_down_resistor
(
GPIO_PinTypeDef
gpio,
GPIO_PullTypeDef
up_down)
;
There are four configurations for up_down.
PM_PIN_PULLUP_1M
PM_PIN_PULLUP_10K
PM_PIN_PULLDOWN_100K
PM_PIN_UP_DOWN_FLOAT
Note: PM_PIN_PULLUP_1M represents x100 pull-up; PM_PIN_PULLUP_10K
represents x1 pull-up; PM_PIN_PULLDOWN_100K represents x10 pull-down.
Analog resistor has a feature: In deepsleep, all states of digital modules are invalid,
including input/output state (cannot output level in deepsleep). However, the
configured analog resistor can still take effect in deepsleep.
GPIO configuration examples:
1) Configure GPIO_PA4 as high level output.
gpio_set_func(GPIO_PA4, AS_GPIO) ;
// PA4 is used as general GPIO function by
default, so this step to configure “func” can be skipped.
gpio_set_input_en(GPIO_PA4, 0);
gpio_set_output_en(GPIO_PA4, 1);