思澈科技软件开发工具包  2.20
Button Library

Sifli button library interface. More...

Data Structures

struct  button_cfg_t
 
enum  button_action_t {
  BUTTON_PRESSED = 0,
  BUTTON_RELEASED = 1,
  BUTTON_LONG_PRESSED = 2,
  BUTTON_CLICKED = 3
}
 
enum  button_active_state_t {
  BUTTON_ACTIVE_LOW = 0,
  BUTTON_ACTIVE_HIGH = 1
}
 
typedef void(* button_handler_t) (int32_t pin, button_action_t button_action)
 
int32_t button_init (button_cfg_t *cfg)
 
sf_err_t button_enable (int32_t id)
 
sf_err_t button_disable (int32_t id)
 
bool button_is_pressed (int32_t id)
 
void button_irq_trigger (int32_t pin)
 
sf_err_t button_update_handler (int32_t id, button_handler_t new_handler)
 

Detailed Description

Sifli button library interface.

Typedef Documentation

◆ button_handler_t

typedef void(* button_handler_t) (int32_t pin, button_action_t button_action)

Button event handler type.

Enumeration Type Documentation

◆ button_action_t

button action type

Enumerator
BUTTON_PRESSED 

Indicates that a button is pressed

BUTTON_RELEASED 

Indicates that a button is released

BUTTON_LONG_PRESSED 

Indicates that a button is long released

BUTTON_CLICKED 

Indicates that a button is clicked

◆ button_active_state_t

button active level

Enumerator
BUTTON_ACTIVE_LOW 

state is low when button is pressed

BUTTON_ACTIVE_HIGH 

state is high when button is pressed

Function Documentation

◆ button_disable()

sf_err_t button_disable ( int32_t  id)

Disable specified button detection.

Parameters
[in]idbutton id allocated by button_init
Return values
SF_EOKButton detection successfully disabled. Error code otherwise.

◆ button_enable()

sf_err_t button_enable ( int32_t  id)

Enable specified button detection.

Parameters
[in]idbutton id allocated by button_init
Return values
SF_EOKbutton successfully enabled.

◆ button_init()

int32_t button_init ( button_cfg_t cfg)

Initialize the button.

Parameters
[in]cfgbutton config
Returns
button id. >=0 on success, otherwise an error code.

◆ button_irq_trigger()

void button_irq_trigger ( int32_t  pin)

Emulate the pin IRQ

Parameters
[in]pinpin
Returns
void

◆ button_is_pressed()

bool button_is_pressed ( int32_t  id)

Check if specified button is currently being pressed.

Parameters
[in]idbutton id allocated by button_init
Returns
true: pressed, false: not pressed

◆ button_update_handler()

sf_err_t button_update_handler ( int32_t  id,
button_handler_t  new_handler 
)

Update button handler

Parameters
[in]idbutton id allocated by button_init
[in]new_handlernew button handler
Returns
SF_EOK handler update succesfully