portexpander.h 1.33 KB
Newer Older
1
2
3
#ifndef PORTEXPANDER_H
#define PORTEXPANDER_H

4
5
#include "mxc_config.h"

6
#include <stdint.h>
7
#include <stdbool.h>
8

9
void portexpander_set(uint8_t pin, uint8_t value);
fleur's avatar
fleur committed
10
11
void portexpander_prep(uint8_t pin, uint8_t value);
void portexpander_update(void);
12
13
14
15
16
17
18
19
20
21
22
23
24
25

/**
 * Structure type for configuring the portexpander.
 */
typedef struct {
        uint8_t mask;           /**< Pin mask (multiple pins may be set) */
        gpio_func_t func;       /**< Function type */
        gpio_pad_t pad;         /**< Pad type */
} portexpander_cfg_t;


typedef void (*pe_callback)(void *cbdata);

int portexpander_init(void);
26
bool portexpander_detected(void);
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int portexpander_config(const portexpander_cfg_t *cfg);

uint8_t portexpander_in_get(uint8_t mask);

void portexpander_out_set(uint8_t mask);
void portexpander_out_clr(uint8_t mask);
void portexpander_out_put(uint8_t mask, uint8_t val);
void portexpander_out_toggle(uint8_t mask);
uint8_t portexpander_out_get(uint8_t mask);

void portexpander_int_config(uint8_t mask, gpio_int_pol_t edge);
void portexpander_int_enable(uint8_t mask);
void portexpander_int_disable(uint8_t mask);
uint8_t portexpander_int_status();
void portexpander_int_clr(uint8_t mask);
int portexpander_register_callback(uint8_t mask, pe_callback callback, void *cbdata);
void portexpander_poll();

void portexpander_interrupt_callback(void *_);

48
#endif