56 lines
1.4 KiB
C
56 lines
1.4 KiB
C
#ifndef MPYATE_HOST_H
|
|
#define MPYATE_HOST_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#define ATE_ADC_CH_IOREF 0
|
|
#define ATE_ADC_CH_IOREF_MASK (1U << ATE_ADC_CH_IOREF)
|
|
|
|
typedef enum {
|
|
ATE_RET_SUCCESS,
|
|
ATE_RET_FAIL,
|
|
ATE_RET_NOT_READY,
|
|
} ate_ret_t;
|
|
|
|
typedef enum {
|
|
ATE_GPIO_MODE_OUTPUT_PP,
|
|
ATE_GPIO_MODE_OUTPUT_OD,
|
|
ATE_GPIO_MODE_INPUT,
|
|
ATE_GPIO_MODE_AF,
|
|
} ate_gpio_mode_t;
|
|
|
|
typedef enum {
|
|
ATE_LED_R,
|
|
ATE_LED_G,
|
|
ATE_LED_B,
|
|
} ate_led_t;
|
|
|
|
typedef ate_ret_t (*ate_i2c_read_t)(void *handle, uint8_t *data, uint8_t len);
|
|
typedef ate_ret_t (*ate_i2c_write_t)(void *handle, uint8_t *data, uint8_t len);
|
|
typedef ate_ret_t (*ate_delay_t)(void *handle, uint32_t msec);
|
|
|
|
typedef struct {
|
|
ate_i2c_read_t read;
|
|
ate_i2c_write_t write;
|
|
ate_delay_t delay;
|
|
} ate_ops_t;
|
|
|
|
typedef struct {
|
|
ate_ops_t ops;
|
|
|
|
void *user_data;
|
|
} ate_t;
|
|
|
|
ate_ret_t ate_init(ate_t *ate);
|
|
ate_ret_t ate_led_set(ate_t *ate, ate_led_t led, bool value);
|
|
ate_ret_t ate_gpio_init(ate_t *ate, uint8_t pin, ate_gpio_mode_t mode);
|
|
ate_ret_t ate_gpio_read(ate_t *ate, uint8_t pin, bool *value);
|
|
ate_ret_t ate_gpio_write(ate_t *ate, uint8_t pin, bool value);
|
|
ate_ret_t ate_adc_configure(ate_t *ate, bool enable, uint8_t ch_mask);
|
|
ate_ret_t ate_adc_status(ate_t *ate, bool *enable);
|
|
ate_ret_t ate_adc_read(ate_t *ate, uint8_t ch, uint16_t *result);
|
|
ate_ret_t ate_dac_set(ate_t *ate, uint16_t da_value);
|
|
|
|
#endif // MPYATE_HOST_H
|