Sync with sample stuffing (#69)
* upgrade to IDF v5.1.1
* add new synchronization implementation, use sample stuffing / removal to keep up sync
* use big DMA buffer for I2S and improve sync
* Add DAC TAS5805M as custom board
* add wifi credential reset
o press reset button (nRESET pin) 3 times
but wait about 1s between button presses
the button press counter is reset 5s after boot
* Add support for PT8211 DAC (#78)
* upgrade ethernet interface to IDF v5 (#84)
* port official example of ethernet for IDF v5.x
* Fix cmake if guard for ethernet
Signed-off-by: Karl Osterseher <karli_o@gmx.at>
Co-authored-by: DerPicknicker <64746593+DerPicknicker@users.noreply.github.com>
Co-authored-by: whc2001 <ianwang0122@outlook.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
fd701a1ead
commit
fae271186c
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,473 +33,486 @@
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Peripheral Identify, this must be unique for each peripheral added
|
||||
* to the peripherals list
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_ID_BUTTON = AUDIO_ELEMENT_TYPE_PERIPH + 1,
|
||||
PERIPH_ID_TOUCH = AUDIO_ELEMENT_TYPE_PERIPH + 2,
|
||||
PERIPH_ID_SDCARD = AUDIO_ELEMENT_TYPE_PERIPH + 3,
|
||||
PERIPH_ID_WIFI = AUDIO_ELEMENT_TYPE_PERIPH + 4,
|
||||
PERIPH_ID_FLASH = AUDIO_ELEMENT_TYPE_PERIPH + 5,
|
||||
PERIPH_ID_AUXIN = AUDIO_ELEMENT_TYPE_PERIPH + 6,
|
||||
PERIPH_ID_ADC = AUDIO_ELEMENT_TYPE_PERIPH + 7,
|
||||
PERIPH_ID_CONSOLE = AUDIO_ELEMENT_TYPE_PERIPH + 8,
|
||||
PERIPH_ID_BLUETOOTH = AUDIO_ELEMENT_TYPE_PERIPH + 9,
|
||||
PERIPH_ID_LED = AUDIO_ELEMENT_TYPE_PERIPH + 10,
|
||||
PERIPH_ID_SPIFFS = AUDIO_ELEMENT_TYPE_PERIPH + 11,
|
||||
PERIPH_ID_ADC_BTN = AUDIO_ELEMENT_TYPE_PERIPH + 12,
|
||||
PERIPH_ID_IS31FL3216 = AUDIO_ELEMENT_TYPE_PERIPH + 13,
|
||||
PERIPH_ID_GPIO_ISR = AUDIO_ELEMENT_TYPE_PERIPH + 14,
|
||||
PERIPH_ID_WS2812 = AUDIO_ELEMENT_TYPE_PERIPH + 15,
|
||||
PERIPH_ID_AW2013 = AUDIO_ELEMENT_TYPE_PERIPH + 16
|
||||
} esp_periph_id_t;
|
||||
/**
|
||||
* @brief Peripheral Identify, this must be unique for each peripheral added to
|
||||
* the peripherals list
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_ID_BUTTON = AUDIO_ELEMENT_TYPE_PERIPH + 1,
|
||||
PERIPH_ID_TOUCH = AUDIO_ELEMENT_TYPE_PERIPH + 2,
|
||||
PERIPH_ID_SDCARD = AUDIO_ELEMENT_TYPE_PERIPH + 3,
|
||||
PERIPH_ID_WIFI = AUDIO_ELEMENT_TYPE_PERIPH + 4,
|
||||
PERIPH_ID_FLASH = AUDIO_ELEMENT_TYPE_PERIPH + 5,
|
||||
PERIPH_ID_AUXIN = AUDIO_ELEMENT_TYPE_PERIPH + 6,
|
||||
PERIPH_ID_ADC = AUDIO_ELEMENT_TYPE_PERIPH + 7,
|
||||
PERIPH_ID_CONSOLE = AUDIO_ELEMENT_TYPE_PERIPH + 8,
|
||||
PERIPH_ID_BLUETOOTH = AUDIO_ELEMENT_TYPE_PERIPH + 9,
|
||||
PERIPH_ID_LED = AUDIO_ELEMENT_TYPE_PERIPH + 10,
|
||||
PERIPH_ID_SPIFFS = AUDIO_ELEMENT_TYPE_PERIPH + 11,
|
||||
PERIPH_ID_ADC_BTN = AUDIO_ELEMENT_TYPE_PERIPH + 12,
|
||||
PERIPH_ID_IS31FL3216 = AUDIO_ELEMENT_TYPE_PERIPH + 13,
|
||||
PERIPH_ID_GPIO_ISR = AUDIO_ELEMENT_TYPE_PERIPH + 14,
|
||||
PERIPH_ID_WS2812 = AUDIO_ELEMENT_TYPE_PERIPH + 15,
|
||||
PERIPH_ID_AW2013 = AUDIO_ELEMENT_TYPE_PERIPH + 16,
|
||||
PERIPH_ID_LCD = AUDIO_ELEMENT_TYPE_PERIPH + 17
|
||||
} esp_periph_id_t;
|
||||
|
||||
/**
|
||||
* @brief Peripheral working state
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_STATE_NULL,
|
||||
PERIPH_STATE_INIT,
|
||||
PERIPH_STATE_RUNNING,
|
||||
PERIPH_STATE_PAUSE,
|
||||
PERIPH_STATE_STOPPING,
|
||||
PERIPH_STATE_ERROR,
|
||||
PERIPH_STATE_STATUS_MAX,
|
||||
} esp_periph_state_t;
|
||||
/**
|
||||
* @brief Peripheral working state
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_STATE_NULL,
|
||||
PERIPH_STATE_INIT,
|
||||
PERIPH_STATE_RUNNING,
|
||||
PERIPH_STATE_PAUSE,
|
||||
PERIPH_STATE_STOPPING,
|
||||
PERIPH_STATE_ERROR,
|
||||
PERIPH_STATE_STATUS_MAX,
|
||||
} esp_periph_state_t;
|
||||
|
||||
typedef struct esp_periph_sets *esp_periph_set_handle_t;
|
||||
typedef struct esp_periph *esp_periph_handle_t;
|
||||
typedef esp_err_t (*esp_periph_func) (esp_periph_handle_t periph);
|
||||
typedef esp_err_t (*esp_periph_run_func) (esp_periph_handle_t periph,
|
||||
audio_event_iface_msg_t *msg);
|
||||
typedef esp_err_t (*esp_periph_event_handle_t) (
|
||||
audio_event_iface_msg_t *event, void *context);
|
||||
typedef void (*timer_callback) (xTimerHandle tmr);
|
||||
typedef struct esp_periph_sets *esp_periph_set_handle_t;
|
||||
typedef struct esp_periph *esp_periph_handle_t;
|
||||
typedef esp_err_t (*esp_periph_func)(esp_periph_handle_t periph);
|
||||
typedef esp_err_t (*esp_periph_run_func)(esp_periph_handle_t periph,
|
||||
audio_event_iface_msg_t *msg);
|
||||
typedef esp_err_t (*esp_periph_event_handle_t)(audio_event_iface_msg_t *event,
|
||||
void *context);
|
||||
typedef void (*timer_callback)(xTimerHandle tmr);
|
||||
|
||||
/**
|
||||
* @brief Common peripherals configurations
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int task_stack; /*!< >0 Service task stack size; =0 without task created */
|
||||
int task_prio; /*!< Service task priority (based on freeRTOS priority) */
|
||||
int task_core; /*!< Service task running in core (0 or 1) */
|
||||
bool extern_stack; /*!< Service task stack allocate on extern ram */
|
||||
} esp_periph_config_t;
|
||||
/**
|
||||
* @brief Common peripherals configurations
|
||||
*/
|
||||
typedef struct {
|
||||
int task_stack; /*!< >0 Service task stack size; =0 without task created */
|
||||
int task_prio; /*!< Service task priority (based on freeRTOS priority) */
|
||||
int task_core; /*!< Service task running in core (0 or 1) */
|
||||
bool extern_stack; /*!< Service task stack allocate on extern ram */
|
||||
} esp_periph_config_t;
|
||||
|
||||
/**
|
||||
* @brief peripheral events
|
||||
*/
|
||||
typedef struct esp_periph_event
|
||||
{
|
||||
void *user_ctx; /*!< peripheral context data */
|
||||
esp_periph_event_handle_t cb; /*!< peripheral callback function */
|
||||
audio_event_iface_handle_t iface; /*!< peripheral event */
|
||||
} esp_periph_event_t;
|
||||
/**
|
||||
* @brief peripheral events
|
||||
*/
|
||||
typedef struct esp_periph_event {
|
||||
void *user_ctx; /*!< peripheral context data */
|
||||
esp_periph_event_handle_t cb; /*!< peripheral callback function */
|
||||
audio_event_iface_handle_t iface; /*!< peripheral event */
|
||||
} esp_periph_event_t;
|
||||
|
||||
#define DEFAULT_ESP_PERIPH_STACK_SIZE (4 * 1024)
|
||||
#define DEFAULT_ESP_PERIPH_TASK_PRIO (5)
|
||||
#define DEFAULT_ESP_PERIPH_TASK_CORE (0)
|
||||
|
||||
#define DEFAULT_ESP_PERIPH_SET_CONFIG() \
|
||||
{ \
|
||||
.task_stack = DEFAULT_ESP_PERIPH_STACK_SIZE, \
|
||||
.task_prio = DEFAULT_ESP_PERIPH_TASK_PRIO, \
|
||||
.task_core = DEFAULT_ESP_PERIPH_TASK_CORE, .extern_stack = false, \
|
||||
#define DEFAULT_ESP_PERIPH_SET_CONFIG() \
|
||||
{ \
|
||||
.task_stack = DEFAULT_ESP_PERIPH_STACK_SIZE, \
|
||||
.task_prio = DEFAULT_ESP_PERIPH_TASK_PRIO, \
|
||||
.task_core = DEFAULT_ESP_PERIPH_TASK_CORE, .extern_stack = false, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize esp_peripheral sets, create empty peripherals list.
|
||||
* Call this function before starting any peripherals (with
|
||||
* `esp_periph_start`). This call will initialize the data needed for
|
||||
* esp_peripherals to work, but does not actually create the task. The
|
||||
* `event_handle` is optional if you want to receive events from this
|
||||
* callback function. The esp_peripherals task will send all events out to
|
||||
* event_iface, can be listen by event_iface by `esp_periph_get_event_iface`.
|
||||
* The `user_context` will sent `esp_periph_event_handle_t` as *context
|
||||
* parameter.
|
||||
*
|
||||
* @param[in] config The configurations
|
||||
*
|
||||
* @return The peripheral sets instance
|
||||
*/
|
||||
esp_periph_set_handle_t esp_periph_set_init (esp_periph_config_t *config);
|
||||
/**
|
||||
* @brief Initialize esp_peripheral sets, create empty peripherals list.
|
||||
* Call this function before starting any peripherals (with
|
||||
* `esp_periph_start`). This call will initialize the data needed for
|
||||
* esp_peripherals to work, but does not actually create the task. The
|
||||
* `event_handle` is optional if you want to receive events from this callback
|
||||
* function. The esp_peripherals task will send all events out to event_iface,
|
||||
* can be listen by event_iface by `esp_periph_get_event_iface`. The
|
||||
* `user_context` will sent `esp_periph_event_handle_t` as *context parameter.
|
||||
*
|
||||
* @param[in] config The configurations
|
||||
*
|
||||
* @return The peripheral sets instance
|
||||
*/
|
||||
esp_periph_set_handle_t esp_periph_set_init(esp_periph_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief This function will stop and kill the monitor task, calling all
|
||||
* destroy callback functions of the peripheral (so you do not need to
|
||||
* destroy the peripheral object manually). It will also remove all memory
|
||||
* allocated to the peripherals list, so you need to call the
|
||||
* `esp_periph_set_init` function again if you want to use it.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_destroy (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief This function will stop and kill the monitor task, calling all
|
||||
* destroy callback functions of the peripheral (so you do not need to destroy
|
||||
* the peripheral object manually). It will also remove all memory allocated to
|
||||
* the peripherals list, so you need to call the `esp_periph_set_init` function
|
||||
* again if you want to use it.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_destroy(esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Stop monitoring all peripherals, the peripheral state is still
|
||||
* kept. This funciton only temporary disables the peripheral.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t
|
||||
esp_periph_set_stop_all (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief Stop monitoring all peripherals, the peripheral state is still
|
||||
* kept. This funciton only temporary disables the peripheral.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_stop_all(esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Get the peripheral handle by Peripheral ID
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @param[in] periph_id as esp_periph_id_t, or any ID you use when calling
|
||||
* `esp_periph_create`
|
||||
*
|
||||
*
|
||||
* @return The esp_periph_handle_t
|
||||
*/
|
||||
esp_periph_handle_t
|
||||
esp_periph_set_get_by_id (esp_periph_set_handle_t periph_set_handle,
|
||||
int periph_id);
|
||||
/**
|
||||
* @brief Get the peripheral handle by Peripheral ID
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @param[in] periph_id as esp_periph_id_t, or any ID you use when calling
|
||||
* `esp_periph_create`
|
||||
*
|
||||
*
|
||||
* @return The esp_periph_handle_t
|
||||
*/
|
||||
esp_periph_handle_t esp_periph_set_get_by_id(
|
||||
esp_periph_set_handle_t periph_set_handle, int periph_id);
|
||||
|
||||
/**
|
||||
* @brief Return the event_iface used by this esp_peripherals
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return The audio event iface handle
|
||||
*/
|
||||
audio_event_iface_handle_t
|
||||
esp_periph_set_get_event_iface (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief Return the event_iface used by this esp_peripherals
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return The audio event iface handle
|
||||
*/
|
||||
audio_event_iface_handle_t esp_periph_set_get_event_iface(
|
||||
esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Register peripheral sets event callback function.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param cb The event handle callback function
|
||||
* @param user_context The user context pointer
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t
|
||||
esp_periph_set_register_callback (esp_periph_set_handle_t periph_set_handle,
|
||||
esp_periph_event_handle_t cb,
|
||||
void *user_context);
|
||||
/**
|
||||
* @brief Register peripheral sets event callback function.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param cb The event handle callback function
|
||||
* @param user_context The user context pointer
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_register_callback(
|
||||
esp_periph_set_handle_t periph_set_handle, esp_periph_event_handle_t cb,
|
||||
void *user_context);
|
||||
|
||||
/**
|
||||
* @brief Peripheral is using event_iface to control the event, all
|
||||
* events are send out to event_iface queue. This function will be useful in
|
||||
* case we want to read events directly from the event_iface queue.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return The queue handle
|
||||
*/
|
||||
QueueHandle_t
|
||||
esp_periph_set_get_queue (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief Peripheral is using event_iface to control the event, all events
|
||||
* are send out to event_iface queue. This function will be useful in case we
|
||||
* want to read events directly from the event_iface queue.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return The queue handle
|
||||
*/
|
||||
QueueHandle_t esp_periph_set_get_queue(
|
||||
esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Call this function to initialize all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t
|
||||
esp_periph_set_list_init (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief Call this function to initialize all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_list_init(esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Call this function to run all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param msg The audio_event_iface_msg_t handle
|
||||
* message
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_list_run (esp_periph_set_handle_t periph_set_handle,
|
||||
audio_event_iface_msg_t msg);
|
||||
/**
|
||||
* @brief Call this function to run all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param msg The audio_event_iface_msg_t handle message
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_list_run(esp_periph_set_handle_t periph_set_handle,
|
||||
audio_event_iface_msg_t msg);
|
||||
|
||||
/**
|
||||
* @brief Call this function to destroy all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t
|
||||
esp_periph_set_list_destroy (esp_periph_set_handle_t periph_set_handle);
|
||||
/**
|
||||
* @brief Call this function to destroy all the listed peripherals.
|
||||
* @note Work with no task peripheral set only
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_list_destroy(
|
||||
esp_periph_set_handle_t periph_set_handle);
|
||||
|
||||
/**
|
||||
* @brief Call this function to initialize a new peripheral
|
||||
*
|
||||
* @param[in] periph_id The periph identifier
|
||||
* @param[in] tag The tag name, we named it easy to get in debug logs
|
||||
*
|
||||
* @return The peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t esp_periph_create (int periph_id, const char *tag);
|
||||
/**
|
||||
* @brief Call this function to remove periph from periph_set.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param periph The esp_periph_handle_t instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_remove_from_set(esp_periph_set_handle_t periph_set_handle,
|
||||
esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Each peripheral has a cycle of sequential operations from
|
||||
* initialization, execution of commands to destroying the peripheral. These
|
||||
* operations are represented by functions passed as call parameters to this
|
||||
* function.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] init The initialize
|
||||
* @param[in] run The run
|
||||
* @param[in] destroy The destroy
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_function (esp_periph_handle_t periph,
|
||||
esp_periph_func init,
|
||||
esp_periph_run_func run,
|
||||
esp_periph_func destroy);
|
||||
/**
|
||||
* @brief Call this function to change periph_set waiting time.
|
||||
*
|
||||
* @param periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param time_ms The waiting time
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_change_waiting_time(
|
||||
esp_periph_set_handle_t periph_set_handle, int time_ms);
|
||||
|
||||
/**
|
||||
* @brief Add the peripheral to peripherals list, enable and start
|
||||
* monitor task (if task stack size > 0)
|
||||
*
|
||||
* @param[in] periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param[in] periph The peripheral instance
|
||||
*
|
||||
* @note
|
||||
* This peripheral must be first created by calling
|
||||
* `esp_periph_create`
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL when any errors
|
||||
*/
|
||||
esp_err_t esp_periph_start (esp_periph_set_handle_t periph_set_handle,
|
||||
esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Call this function to initialize a new peripheral
|
||||
*
|
||||
* @param[in] periph_id The periph identifier
|
||||
* @param[in] tag The tag name, we named it easy to get in debug logs
|
||||
*
|
||||
* @return The peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t esp_periph_create(int periph_id, const char *tag);
|
||||
|
||||
/**
|
||||
* @brief Stop monitoring the peripheral, the peripheral state is still
|
||||
* kept. This funciton only temporary disables the peripheral.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_stop (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Each peripheral has a cycle of sequential operations from
|
||||
* initialization, execution of commands to destroying the peripheral. These
|
||||
* operations are represented by functions passed as call parameters to this
|
||||
* function.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] init The initialize
|
||||
* @param[in] run The run
|
||||
* @param[in] destroy The destroy
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_function(esp_periph_handle_t periph,
|
||||
esp_periph_func init, esp_periph_run_func run,
|
||||
esp_periph_func destroy);
|
||||
|
||||
/**
|
||||
* @brief When this function is called, the command is passed to the
|
||||
* event_iface command queue, and the `esp_periph_run_func` of this
|
||||
* peripheral will be executed in the main peripheral task. This function can
|
||||
* be called from any task, basically it only sends a queue to the main
|
||||
* peripheral task
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] cmd The command
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_cmd (esp_periph_handle_t periph, int cmd,
|
||||
void *data, int data_len);
|
||||
/**
|
||||
* @brief Add the peripheral to peripherals list, enable and start monitor
|
||||
* task (if task stack size > 0)
|
||||
*
|
||||
* @param[in] periph_set_handle The esp_periph_set_handle_t instance
|
||||
* @param[in] periph The peripheral instance
|
||||
*
|
||||
* @note
|
||||
* This peripheral must be first created by calling `esp_periph_create`
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL when any errors
|
||||
*/
|
||||
esp_err_t esp_periph_start(esp_periph_set_handle_t periph_set_handle,
|
||||
esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Similar to `esp_periph_send_cmd`, but it can be called in the
|
||||
* hardware interrupt handle
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] cmd The command
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_cmd_from_isr (esp_periph_handle_t periph, int cmd,
|
||||
void *data, int data_len);
|
||||
/**
|
||||
* @brief Stop monitoring the peripheral, the peripheral state is still
|
||||
* kept. This funciton only temporary disables the peripheral.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_stop(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief In addition to sending an event via event_iface, this function
|
||||
* will dispatch the `event_handle` callback if the event_handle callback is
|
||||
* provided at `esp_periph_init`
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] event_id The event identifier
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_event (esp_periph_handle_t periph, int event_id,
|
||||
void *data, int data_len);
|
||||
/**
|
||||
* @brief When this function is called, the command is passed to the
|
||||
* event_iface command queue, and the `esp_periph_run_func` of this peripheral
|
||||
* will be executed in the main peripheral task. This function can be called
|
||||
* from any task, basically it only sends a queue to the main peripheral task
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] cmd The command
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_cmd(esp_periph_handle_t periph, int cmd, void *data,
|
||||
int data_len);
|
||||
|
||||
/**
|
||||
* @brief Each peripheral can initialize a timer, which is by default
|
||||
* NULL. When this function is called, the timer for the peripheral is
|
||||
* created and it invokes the callback function every interval tick.
|
||||
*
|
||||
* @note
|
||||
* - You do not need to stop or destroy the timer, when the
|
||||
* `esp_periph_destroy` function is called, it will stop and destroy all
|
||||
* - This timer using FreeRTOS Timer, with autoreload = true
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] interval_tick The interval tick
|
||||
* @param[in] callback The callback
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_start_timer (esp_periph_handle_t periph,
|
||||
TickType_t interval_tick,
|
||||
timer_callback callback);
|
||||
/**
|
||||
* @brief Similar to `esp_periph_send_cmd`, but it can be called in the
|
||||
* hardware interrupt handle
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] cmd The command
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_cmd_from_isr(esp_periph_handle_t periph, int cmd,
|
||||
void *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief Stop peripheral timer
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_stop_timer (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief In addition to sending an event via event_iface, this function
|
||||
* will dispatch the `event_handle` callback if the event_handle callback is
|
||||
* provided at `esp_periph_init`
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] event_id The event identifier
|
||||
* @param data The data
|
||||
* @param[in] data_len The data length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_send_event(esp_periph_handle_t periph, int event_id,
|
||||
void *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief Set the user data
|
||||
*
|
||||
* @note Make sure the `data` lifetime is sufficient, this function
|
||||
* does not copy all data, it only stores the data pointer
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param data The data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_data (esp_periph_handle_t periph, void *data);
|
||||
/**
|
||||
* @brief Each peripheral can initialize a timer, which is by default NULL.
|
||||
* When this function is called, the timer for the peripheral is
|
||||
* created and it invokes the callback function every interval tick.
|
||||
*
|
||||
* @note
|
||||
* - You do not need to stop or destroy the timer, when the
|
||||
* `esp_periph_destroy` function is called, it will stop and destroy all
|
||||
* - This timer using FreeRTOS Timer, with autoreload = true
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] interval_tick The interval tick
|
||||
* @param[in] callback The callback
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_start_timer(esp_periph_handle_t periph,
|
||||
TickType_t interval_tick,
|
||||
timer_callback callback);
|
||||
|
||||
/**
|
||||
* @brief Get the user data stored in the peripheral
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return Peripheral data pointer
|
||||
*/
|
||||
void *esp_periph_get_data (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Stop peripheral timer
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_stop_timer(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Get the current state of peripheral.
|
||||
*
|
||||
* @param[in] periph The handle of peripheral
|
||||
*
|
||||
* @return The peripharal working state
|
||||
*/
|
||||
esp_periph_state_t esp_periph_get_state (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Set the user data
|
||||
*
|
||||
* @note Make sure the `data` lifetime is sufficient, this function does
|
||||
* not copy all data, it only stores the data pointer
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param data The data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_data(esp_periph_handle_t periph, void *data);
|
||||
|
||||
/**
|
||||
* @brief Get Peripheral identifier
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return The peripheral identifier
|
||||
*/
|
||||
esp_periph_id_t esp_periph_get_id (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Get the user data stored in the peripheral
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return Peripheral data pointer
|
||||
*/
|
||||
void *esp_periph_get_data(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Set Peripheral identifier
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] periph_id The peripheral identifier
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_id (esp_periph_handle_t periph,
|
||||
esp_periph_id_t periph_id);
|
||||
/**
|
||||
* @brief Get the current state of peripheral.
|
||||
*
|
||||
* @param[in] periph The handle of peripheral
|
||||
*
|
||||
* @return The peripharal working state
|
||||
*/
|
||||
esp_periph_state_t esp_periph_get_state(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Call this to execute `init` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_init (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Get Peripheral identifier
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
*
|
||||
* @return The peripheral identifier
|
||||
*/
|
||||
esp_periph_id_t esp_periph_get_id(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Call this to execute `run` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_run (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Set Peripheral identifier
|
||||
*
|
||||
* @param[in] periph The peripheral
|
||||
* @param[in] periph_id The peripheral identifier
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_set_id(esp_periph_handle_t periph,
|
||||
esp_periph_id_t periph_id);
|
||||
|
||||
/**
|
||||
* @brief Call this to execute `destroy` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_destroy (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Call this to execute `init` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_init(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Rigster peripheral on event handle
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
* @param evts The esp_periph_event_t handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_register_on_events (esp_periph_handle_t periph,
|
||||
esp_periph_event_t *evts);
|
||||
/**
|
||||
* @brief Call this to execute `run` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_run(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Call this to execute `destroy` function of peripheral instance
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_destroy(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Rigster peripheral on event handle
|
||||
*
|
||||
* @param periph The peripheral handle
|
||||
* @param evts The esp_periph_event_t handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_periph_register_on_events(esp_periph_handle_t periph,
|
||||
esp_periph_event_t *evts);
|
||||
|
||||
#define periph_tick_get esp_periph_tick_get
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,73 +32,70 @@
|
||||
#include "esp_peripherals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ADC_BUTTON_STACK_SIZE 2500
|
||||
#define ADC_BUTTON_TASK_PRIORITY 10
|
||||
#define ADC_BUTTON_TASK_CORE_ID 0
|
||||
|
||||
/**
|
||||
* @brief The configuration of ADC Button
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
adc_arr_t *arr; /*!< An array with configuration of buttons */
|
||||
int arr_size; /*!< The array size */
|
||||
adc_btn_task_cfg_t task_cfg; /*!< Adc button task configuration */
|
||||
} periph_adc_button_cfg_t;
|
||||
/**
|
||||
* @brief The configuration of ADC Button
|
||||
*/
|
||||
typedef struct {
|
||||
adc_arr_t *arr; /*!< An array with configuration of buttons */
|
||||
int arr_size; /*!< The array size */
|
||||
adc_btn_task_cfg_t task_cfg; /*!< Adc button task configuration */
|
||||
} periph_adc_button_cfg_t;
|
||||
|
||||
#define PERIPH_ADC_BUTTON_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.task_cfg \
|
||||
= {.task_stack = ADC_BUTTON_STACK_SIZE, \
|
||||
.task_core = ADC_BUTTON_TASK_CORE_ID, \
|
||||
.task_prio = ADC_BUTTON_TASK_PRIORITY, \
|
||||
.ext_stack = false } \
|
||||
#define PERIPH_ADC_BUTTON_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.task_cfg = { \
|
||||
.task_stack = ADC_BUTTON_STACK_SIZE, \
|
||||
.task_core = ADC_BUTTON_TASK_CORE_ID, \
|
||||
.task_prio = ADC_BUTTON_TASK_PRIORITY, \
|
||||
.ext_stack = false \
|
||||
} \
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_ADC_BUTTON_IDLE = 0,
|
||||
PERIPH_ADC_BUTTON_PRESSED,
|
||||
PERIPH_ADC_BUTTON_RELEASE,
|
||||
PERIPH_ADC_BUTTON_LONG_PRESSED,
|
||||
PERIPH_ADC_BUTTON_LONG_RELEASE,
|
||||
} periph_adc_button_event_id_t;
|
||||
typedef enum {
|
||||
PERIPH_ADC_BUTTON_IDLE = 0,
|
||||
PERIPH_ADC_BUTTON_PRESSED,
|
||||
PERIPH_ADC_BUTTON_RELEASE,
|
||||
PERIPH_ADC_BUTTON_LONG_PRESSED,
|
||||
PERIPH_ADC_BUTTON_LONG_RELEASE,
|
||||
} periph_adc_button_event_id_t;
|
||||
|
||||
/**
|
||||
* ESP32 ADC1 channels and GPIO table
|
||||
* ADC1_CHANNEL_0 - GPIO36
|
||||
* ADC1_CHANNEL_1 - GPIO37
|
||||
* ADC1_CHANNEL_2 - GPIO38
|
||||
* ADC1_CHANNEL_3 - GPIO39
|
||||
* ADC1_CHANNEL_4 - GPIO32
|
||||
* ADC1_CHANNEL_5 - GPIO33
|
||||
* ADC1_CHANNEL_6 - GPIO34
|
||||
* ADC1_CHANNEL_7 - GPIO35
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* ESP32 ADC1 channels and GPIO table
|
||||
* ADC1_CHANNEL_0 - GPIO36
|
||||
* ADC1_CHANNEL_1 - GPIO37
|
||||
* ADC1_CHANNEL_2 - GPIO38
|
||||
* ADC1_CHANNEL_3 - GPIO39
|
||||
* ADC1_CHANNEL_4 - GPIO32
|
||||
* ADC1_CHANNEL_5 - GPIO33
|
||||
* ADC1_CHANNEL_6 - GPIO34
|
||||
* ADC1_CHANNEL_7 - GPIO35
|
||||
*
|
||||
**/
|
||||
|
||||
#define ADC_DEFAULT_ARR() \
|
||||
{ \
|
||||
.adc_ch = ADC1_CHANNEL_3, .adc_level_step = NULL, .total_steps = 6, \
|
||||
.press_judge_time = 3000, \
|
||||
#define ADC_DEFAULT_ARR() \
|
||||
{ \
|
||||
.adc_ch = ADC1_CHANNEL_3, .adc_level_step = NULL, .total_steps = 6, \
|
||||
.press_judge_time = 3000, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create the button peripheral handle for esp_peripherals.
|
||||
*
|
||||
* @note The handle created by this function is automatically destroyed
|
||||
* when esp_periph_destroy is called.
|
||||
*
|
||||
* @param btn_cfg The button configuration.
|
||||
*
|
||||
* @return The esp peripheral handle.
|
||||
*/
|
||||
esp_periph_handle_t
|
||||
periph_adc_button_init (periph_adc_button_cfg_t *btn_cfg);
|
||||
/**
|
||||
* @brief Create the button peripheral handle for esp_peripherals.
|
||||
*
|
||||
* @note The handle created by this function is automatically destroyed
|
||||
* when esp_periph_destroy is called.
|
||||
*
|
||||
* @param btn_cfg The button configuration.
|
||||
*
|
||||
* @return The esp peripheral handle.
|
||||
*/
|
||||
esp_periph_handle_t periph_adc_button_init(periph_adc_button_cfg_t *btn_cfg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -31,104 +31,100 @@
|
||||
#include "esp_peripherals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AW2013_MODE_LED,
|
||||
AW2013_MODE_FADE,
|
||||
AW2013_MODE_AUTO
|
||||
} periph_aw2013_mode_t;
|
||||
typedef enum {
|
||||
AW2013_MODE_LED,
|
||||
AW2013_MODE_FADE,
|
||||
AW2013_MODE_AUTO
|
||||
} periph_aw2013_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration of aw2013
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
periph_aw2013_mode_t mode; /*!< Work mode of aw2013 */
|
||||
aw2013_brightness_t bright; /*!< The brightness of aw2013 */
|
||||
uint32_t rgb_value; /*!< rgb value to be set */
|
||||
} periph_aw2013_cfg_t;
|
||||
/**
|
||||
* @brief Configuration of aw2013
|
||||
*/
|
||||
typedef struct {
|
||||
periph_aw2013_mode_t mode; /*!< Work mode of aw2013 */
|
||||
aw2013_brightness_t bright; /*!< The brightness of aw2013 */
|
||||
uint32_t rgb_value; /*!< rgb value to be set */
|
||||
} periph_aw2013_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Initializate aw2013
|
||||
*
|
||||
* @param aw2013_cfg Parameters of aw2013
|
||||
*
|
||||
* @return
|
||||
* - NULL Error
|
||||
* - others Success
|
||||
*/
|
||||
esp_periph_handle_t periph_aw2013_init (periph_aw2013_cfg_t *aw2013_cfg);
|
||||
/**
|
||||
* @brief Initializate aw2013
|
||||
*
|
||||
* @param aw2013_cfg Parameters of aw2013
|
||||
*
|
||||
* @return
|
||||
* - NULL Error
|
||||
* - others Success
|
||||
*/
|
||||
esp_periph_handle_t periph_aw2013_init(periph_aw2013_cfg_t *aw2013_cfg);
|
||||
|
||||
/**
|
||||
* @brief Set the brightness of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param bright The brightness to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_brightless (esp_periph_handle_t periph,
|
||||
aw2013_brightness_t bright);
|
||||
/**
|
||||
* @brief Set the brightness of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param bright The brightness to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_brightless(esp_periph_handle_t periph,
|
||||
aw2013_brightness_t bright);
|
||||
|
||||
/**
|
||||
* @brief Set the time periods of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param time The time period to be set
|
||||
* @param level The time value to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_time (esp_periph_handle_t periph,
|
||||
aw2013_time_t time,
|
||||
aw2013_time_level_t level);
|
||||
/**
|
||||
* @brief Set the time periods of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param time The time period to be set
|
||||
* @param level The time value to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_time(esp_periph_handle_t periph, aw2013_time_t time,
|
||||
aw2013_time_level_t level);
|
||||
|
||||
/**
|
||||
* @brief Set the work mode of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param mode The work mode to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_mode (esp_periph_handle_t periph,
|
||||
periph_aw2013_mode_t mode);
|
||||
/**
|
||||
* @brief Set the work mode of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param mode The work mode to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_mode(esp_periph_handle_t periph,
|
||||
periph_aw2013_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Set the rgb value of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param value The value for rgb to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_rgb_value (esp_periph_handle_t periph,
|
||||
uint32_t value);
|
||||
/**
|
||||
* @brief Set the rgb value of aw2013
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param value The value for rgb to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_rgb_value(esp_periph_handle_t periph,
|
||||
uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Set the repeat time in auto flash mode
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param cnt Cycle times to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_repeat_time (esp_periph_handle_t periph,
|
||||
uint8_t cnt);
|
||||
/**
|
||||
* @brief Set the repeat time in auto flash mode
|
||||
*
|
||||
* @param periph The aw2013's handle
|
||||
* @param cnt Cycle times to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Error
|
||||
*/
|
||||
esp_err_t periph_aw2013_set_repeat_time(esp_periph_handle_t periph,
|
||||
uint8_t cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,61 +18,55 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BUTTON_DEV_H_
|
||||
#define _BUTTON_DEV_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The Button peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t gpio_mask; /*!< GPIO Mask using for this Button peripheral, it is
|
||||
BIT(GPIO_NUM), ex: GPIO_SEL_36 | GPIO_SEL_36 */
|
||||
int long_press_time_ms; /*!< Long press duration in milliseconds, default
|
||||
is 2000ms */
|
||||
} periph_button_cfg_t;
|
||||
/**
|
||||
* @brief The Button peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t gpio_mask; /*!< GPIO Mask using for this Button peripheral, it is
|
||||
BIT(GPIO_NUM), ex: GPIO_SEL_36 | GPIO_SEL_36 */
|
||||
int long_press_time_ms; /*!< Long press duration in milliseconds, default is
|
||||
2000ms */
|
||||
} periph_button_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Peripheral button event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_BUTTON_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_BUTTON_PRESSED, /*!< When button is pressed */
|
||||
PERIPH_BUTTON_RELEASE, /*!< When button is released */
|
||||
PERIPH_BUTTON_LONG_PRESSED, /*!< When button is pressed and kept for more
|
||||
than `long_press_time_ms` */
|
||||
PERIPH_BUTTON_LONG_RELEASE, /*!< When button is released and event
|
||||
PERIPH_BUTTON_LONG_PRESSED happened */
|
||||
} periph_button_event_id_t;
|
||||
/**
|
||||
* @brief Peripheral button event id
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_BUTTON_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_BUTTON_PRESSED, /*!< When button is pressed */
|
||||
PERIPH_BUTTON_RELEASE, /*!< When button is released */
|
||||
PERIPH_BUTTON_LONG_PRESSED, /*!< When button is pressed and kept for more than
|
||||
`long_press_time_ms` */
|
||||
PERIPH_BUTTON_LONG_RELEASE, /*!< When button is released and event
|
||||
PERIPH_BUTTON_LONG_PRESSED happened */
|
||||
} periph_button_event_id_t;
|
||||
|
||||
/**
|
||||
* @brief Create the button peripheral handle for esp_peripherals.
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param but_cfg The but configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_button_init (periph_button_cfg_t *but_cfg);
|
||||
/**
|
||||
* @brief Create the button peripheral handle for esp_peripherals.
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param but_cfg The but configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_button_init(periph_button_cfg_t* but_cfg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,69 +18,61 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERIPH_CONSOLE_H_
|
||||
#define _PERIPH_CONSOLE_H_
|
||||
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef esp_err_t (*console_cmd_callback_t) (esp_periph_handle_t periph,
|
||||
int argc, char *argv[]);
|
||||
typedef esp_err_t (*console_cmd_callback_t)(esp_periph_handle_t periph,
|
||||
int argc, char *argv[]);
|
||||
|
||||
#define CONSOLE_DEFAULT_TASK_PRIO (5)
|
||||
#define CONSOLE_DEFAULT_TASK_STACK (1024 * 5)
|
||||
#define CONSOLE_DEFAULT_BUFFER_SIZE (256)
|
||||
#define CONSOLE_DEFAULT_PROMPT_STRING "esp32>"
|
||||
|
||||
/**
|
||||
* @brief Command structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *cmd; /*!< Name of command, must be unique */
|
||||
int id; /*!< Command ID will be sent together when the command is matched
|
||||
*/
|
||||
const char *help; /*!< Explanation of the command */
|
||||
console_cmd_callback_t func; /*!< Function callback for the command */
|
||||
} periph_console_cmd_t;
|
||||
/**
|
||||
* @brief Command structure
|
||||
*/
|
||||
typedef struct {
|
||||
const char *cmd; /*!< Name of command, must be unique */
|
||||
int id; /*!< Command ID will be sent together when the command is matched */
|
||||
const char *help; /*!< Explanation of the command */
|
||||
console_cmd_callback_t func; /*!< Function callback for the command */
|
||||
} periph_console_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief Console Peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int command_num; /*!< Total number of commands */
|
||||
const periph_console_cmd_t *commands; /*!< Pointer to array of commands */
|
||||
int task_stack; /*!< Console task stack, using default if the value is zero
|
||||
*/
|
||||
int task_prio; /*!< Console task priority (based on freeRTOS priority),
|
||||
using default if the value is zero */
|
||||
int buffer_size; /*!< Size of console input buffer */
|
||||
const char
|
||||
*prompt_string; /*!< Console prompt string, using default
|
||||
CONSOLE_PROMPT_STRING if the pointer is NULL */
|
||||
} periph_console_cfg_t;
|
||||
/**
|
||||
* @brief Console Peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
int command_num; /*!< Total number of commands */
|
||||
const periph_console_cmd_t *commands; /*!< Pointer to array of commands */
|
||||
int task_stack; /*!< Console task stack, using default if the value is zero */
|
||||
int task_prio; /*!< Console task priority (based on freeRTOS priority), using
|
||||
default if the value is zero */
|
||||
int buffer_size; /*!< Size of console input buffer */
|
||||
const char *prompt_string; /*!< Console prompt string, using default
|
||||
CONSOLE_PROMPT_STRING if the pointer is NULL */
|
||||
} periph_console_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize Console Peripheral
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_console_init (periph_console_cfg_t *config);
|
||||
/**
|
||||
* @brief Initialize Console Peripheral
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_console_init(periph_console_cfg_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,59 +32,56 @@
|
||||
#include "gpio_isr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @breif Set the gpio number and gpio interruption type
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int gpio_num; /*!< gpio number */
|
||||
gpio_int_type_t type; /*!< interruption type */
|
||||
} gpio_isr_info_t;
|
||||
/**
|
||||
* @breif Set the gpio number and gpio interruption type
|
||||
*/
|
||||
typedef struct {
|
||||
int gpio_num; /*!< gpio number */
|
||||
gpio_int_type_t type; /*!< interruption type */
|
||||
} gpio_isr_info_t;
|
||||
|
||||
/**
|
||||
* @brief The configuration of gpio isr
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int info_size; /*!< number of gpio to be register */
|
||||
gpio_isr_info_t *gpio_isr_info; /*!< an array of gpio's infomation */
|
||||
} periph_gpio_isr_cfg_t;
|
||||
/**
|
||||
* @brief The configuration of gpio isr
|
||||
*/
|
||||
typedef struct {
|
||||
int info_size; /*!< number of gpio to be register */
|
||||
gpio_isr_info_t *gpio_isr_info; /*!< an array of gpio's infomation */
|
||||
} periph_gpio_isr_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the gpio's interrupt service routines handle for
|
||||
* esp_peripherals
|
||||
*
|
||||
* @param isr_config The gpio isr configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_gpio_isr_init (periph_gpio_isr_cfg_t *isr_config);
|
||||
/**
|
||||
* @brief Create the gpio's interrupt service routines handle for
|
||||
* esp_peripherals
|
||||
*
|
||||
* @param isr_config The gpio isr configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_gpio_isr_init(periph_gpio_isr_cfg_t *isr_config);
|
||||
|
||||
/**
|
||||
* @breif Add a gpio to isr
|
||||
*
|
||||
* @param gpio_info The gpio interruption type and gpio number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_FAIL fail
|
||||
*/
|
||||
esp_err_t periph_gpio_isr_add (gpio_isr_info_t *gpio_info);
|
||||
/**
|
||||
* @breif Add a gpio to isr
|
||||
*
|
||||
* @param gpio_info The gpio interruption type and gpio number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_FAIL fail
|
||||
*/
|
||||
esp_err_t periph_gpio_isr_add(gpio_isr_info_t *gpio_info);
|
||||
|
||||
/**
|
||||
* @brief Unregister a gpio from isr
|
||||
*
|
||||
* @param The number of gpio to be unregistered
|
||||
*
|
||||
*@return
|
||||
* - ESP_OK success
|
||||
* - ESP_FAIL failed
|
||||
*/
|
||||
esp_err_t periph_gpio_isr_delete (int gpio_num);
|
||||
/**
|
||||
* @brief Unregister a gpio from isr
|
||||
*
|
||||
* @param The number of gpio to be unregistered
|
||||
*
|
||||
*@return
|
||||
* - ESP_OK success
|
||||
* - ESP_FAIL failed
|
||||
*/
|
||||
esp_err_t periph_gpio_isr_delete(int gpio_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef __PERIPH_IS31FL3216_H__
|
||||
@@ -29,160 +29,155 @@
|
||||
#include "esp_peripherals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IS31FL3216_CH_NUM 16 // Should be less than or equal to 16
|
||||
#define IS31FL3216_CH_NUM 16 // Should be less than or equal to 16
|
||||
#define BLUE_LED_MAX_NUM 12
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IS31FL3216_STATE_UNKNOWN,
|
||||
IS31FL3216_STATE_OFF,
|
||||
IS31FL3216_STATE_ON,
|
||||
IS31FL3216_STATE_FLASH,
|
||||
IS31FL3216_STATE_BY_AUDIO,
|
||||
IS31FL3216_STATE_SHIFT,
|
||||
} periph_is31fl3216_state_t;
|
||||
typedef enum {
|
||||
IS31FL3216_STATE_UNKNOWN,
|
||||
IS31FL3216_STATE_OFF,
|
||||
IS31FL3216_STATE_ON,
|
||||
IS31FL3216_STATE_FLASH,
|
||||
IS31FL3216_STATE_BY_AUDIO,
|
||||
IS31FL3216_STATE_SHIFT,
|
||||
} periph_is31fl3216_state_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_IS31_SHIFT_MODE_UNKNOWN,
|
||||
PERIPH_IS31_SHIFT_MODE_ACC, /*!< accumulation mode */
|
||||
PERIPH_IS31_SHIFT_MODE_SINGLE,
|
||||
} periph_is31_shift_mode_t;
|
||||
typedef enum {
|
||||
PERIPH_IS31_SHIFT_MODE_UNKNOWN,
|
||||
PERIPH_IS31_SHIFT_MODE_ACC, /*!< accumulation mode */
|
||||
PERIPH_IS31_SHIFT_MODE_SINGLE,
|
||||
} periph_is31_shift_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The configuration of is31fl3216
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t duty[IS31FL3216_CH_NUM]; /*!<An array of the is31fl3216's duty*/
|
||||
uint16_t is31fl3216_pattern; /*!<Current enable channel*/
|
||||
periph_is31fl3216_state_t state; /*!<The state of all the channels*/
|
||||
} periph_is31fl3216_cfg_t;
|
||||
/**
|
||||
* @brief The configuration of is31fl3216
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t duty[IS31FL3216_CH_NUM]; /*!<An array of the is31fl3216's duty*/
|
||||
uint16_t is31fl3216_pattern; /*!<Current enable channel*/
|
||||
periph_is31fl3216_state_t state; /*!<The state of all the channels*/
|
||||
} periph_is31fl3216_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Initializate the is31fl3216
|
||||
*
|
||||
* @param is31fl3216_config
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_periph_handle_t
|
||||
periph_is31fl3216_init (periph_is31fl3216_cfg_t *is31fl3216_config);
|
||||
/**
|
||||
* @brief Initializate the is31fl3216
|
||||
*
|
||||
* @param is31fl3216_config
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_periph_handle_t periph_is31fl3216_init(
|
||||
periph_is31fl3216_cfg_t *is31fl3216_config);
|
||||
|
||||
/**
|
||||
* @brief Set the state of all the channels
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param state The state of all channels
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_state (esp_periph_handle_t periph,
|
||||
periph_is31fl3216_state_t state);
|
||||
/**
|
||||
* @brief Set the state of all the channels
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param state The state of all channels
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_state(esp_periph_handle_t periph,
|
||||
periph_is31fl3216_state_t state);
|
||||
|
||||
/**
|
||||
* @brief Set the current enable channels
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param blink_pattern The bit pattern of enabled channels
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_blink_pattern (esp_periph_handle_t periph,
|
||||
uint16_t blink_pattern);
|
||||
/**
|
||||
* @brief Set the current enable channels
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param blink_pattern The bit pattern of enabled channels
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_blink_pattern(esp_periph_handle_t periph,
|
||||
uint16_t blink_pattern);
|
||||
|
||||
/**
|
||||
* @brief Set the duty of the channel
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param index The channel number
|
||||
* @param value The value of the channel's duty to be
|
||||
* set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_duty (esp_periph_handle_t periph,
|
||||
uint8_t index, uint8_t value);
|
||||
/**
|
||||
* @brief Set the duty of the channel
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param index The channel number
|
||||
* @param value The value of the channel's duty to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_duty(esp_periph_handle_t periph, uint8_t index,
|
||||
uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Set the duty step of flash
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param step The step of flash
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_duty_step (esp_periph_handle_t periph,
|
||||
uint8_t step);
|
||||
/**
|
||||
* @brief Set the duty step of flash
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param step The step of flash
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_duty_step(esp_periph_handle_t periph,
|
||||
uint8_t step);
|
||||
|
||||
/**
|
||||
* @brief Set the internval time
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param interval_ms Time of interval
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_interval (esp_periph_handle_t periph,
|
||||
uint16_t interval_ms);
|
||||
/**
|
||||
* @brief Set the internval time
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param interval_ms Time of interval
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_interval(esp_periph_handle_t periph,
|
||||
uint16_t interval_ms);
|
||||
|
||||
/**
|
||||
* @brief Set the shift mode
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param mode Mode of periph_is31_shift_mode_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_shift_mode (esp_periph_handle_t periph,
|
||||
periph_is31_shift_mode_t mode);
|
||||
/**
|
||||
* @brief Set the shift mode
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param mode Mode of periph_is31_shift_mode_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_shift_mode(esp_periph_handle_t periph,
|
||||
periph_is31_shift_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Set the light on numbers
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param light_on_num Enabled led number
|
||||
* @param max_light_num Maximum led number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_light_on_num (esp_periph_handle_t periph,
|
||||
uint16_t light_on_num,
|
||||
uint16_t max_light_num);
|
||||
/**
|
||||
* @brief Set the light on numbers
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param light_on_num Enabled led number
|
||||
* @param max_light_num Maximum led number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_light_on_num(esp_periph_handle_t periph,
|
||||
uint16_t light_on_num,
|
||||
uint16_t max_light_num);
|
||||
|
||||
/**
|
||||
* @brief Set the action time
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param act_ms Action time, unit is millisecond, 0 is
|
||||
* infinite
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_act_time (esp_periph_handle_t periph,
|
||||
uint16_t act_ms);
|
||||
/**
|
||||
* @brief Set the action time
|
||||
*
|
||||
* @param periph The is31fl3216 handle
|
||||
* @param act_ms Action time, unit is millisecond, 0 is
|
||||
* infinite
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t periph_is31fl3216_set_act_time(esp_periph_handle_t periph,
|
||||
uint16_t act_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
97
components/esp_peripherals/include/periph_lcd.h
Normal file
97
components/esp_peripherals/include/periph_lcd.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2021 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERIPH_LCD_H_
|
||||
#define _PERIPH_LCD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0))
|
||||
#include "driver/spi_master.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_peripherals.h"
|
||||
|
||||
typedef esp_err_t (*perph_lcd_rest)(esp_periph_handle_t self, void *ctx);
|
||||
|
||||
typedef esp_err_t (*get_lcd_io_bus)(void *bus,
|
||||
esp_lcd_panel_io_spi_config_t *io_config,
|
||||
esp_lcd_panel_io_handle_t *out_panel_io);
|
||||
|
||||
typedef esp_err_t (*get_lcd_panel)(
|
||||
const esp_lcd_panel_io_handle_t panel_io,
|
||||
const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||
esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
/**
|
||||
* @brief The LCD peripheral configurations
|
||||
*/
|
||||
typedef struct {
|
||||
void *io_bus;
|
||||
get_lcd_io_bus new_panel_io;
|
||||
esp_lcd_panel_io_spi_config_t *lcd_io_cfg;
|
||||
|
||||
get_lcd_panel new_lcd_panel;
|
||||
esp_lcd_panel_dev_config_t *lcd_dev_cfg;
|
||||
perph_lcd_rest rest_cb;
|
||||
void *rest_cb_ctx;
|
||||
|
||||
bool lcd_swap_xy;
|
||||
bool lcd_mirror_x;
|
||||
bool lcd_mirror_y;
|
||||
bool lcd_color_invert;
|
||||
} periph_lcd_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the LCD peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_lcd_init(periph_lcd_cfg_t *config);
|
||||
|
||||
/**
|
||||
* @brief Get the `esp_lcd_panel_handle_t` with given LCD peripheral handle
|
||||
*
|
||||
* @param handle The LCD peripheral handle
|
||||
*
|
||||
* @return The `esp_lcd_panel_handle_t` handle
|
||||
*/
|
||||
esp_lcd_panel_handle_t periph_lcd_get_panel_handle(esp_periph_handle_t handle);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,108 +18,99 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERIPH_LED_H_
|
||||
#define _PERIPH_LED_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Peripheral LED event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_LED_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_LED_BLINK_FINISH, /*!< When LED blink is finished */
|
||||
} periph_led_event_id_t;
|
||||
/**
|
||||
* @brief Peripheral LED event id
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_LED_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_LED_BLINK_FINISH, /*!< When LED blink is finished */
|
||||
} periph_led_event_id_t;
|
||||
|
||||
/**
|
||||
* @brief Peripheral LED idle output level
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_LED_IDLE_LEVEL_LOW, /*!< Low level output */
|
||||
PERIPH_LED_IDLE_LEVEL_HIGH /*!< High level output */
|
||||
} periph_led_idle_level_t;
|
||||
/**
|
||||
* @brief Peripheral LED idle output level
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_LED_IDLE_LEVEL_LOW, /*!< Low level output */
|
||||
PERIPH_LED_IDLE_LEVEL_HIGH /*!< High level output */
|
||||
} periph_led_idle_level_t;
|
||||
|
||||
/**
|
||||
* @brief The LED peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ledc_mode_t led_speed_mode; /*!< LEDC speed speed_mode, high-speed mode or
|
||||
low-speed mode */
|
||||
ledc_timer_bit_t led_duty_resolution; /*!< LEDC channel duty resolution */
|
||||
ledc_timer_t
|
||||
led_timer_num; /*!< Select the timer source of channel (0 - 3) */
|
||||
uint32_t led_freq_hz; /*!< LEDC timer frequency (Hz) */
|
||||
int gpio_num; /*!< Optional, < 0 invalid gpio number */
|
||||
} periph_led_cfg_t;
|
||||
/**
|
||||
* @brief The LED peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
ledc_mode_t led_speed_mode; /*!< LEDC speed speed_mode, high-speed mode or
|
||||
low-speed mode */
|
||||
ledc_timer_bit_t led_duty_resolution; /*!< LEDC channel duty resolution */
|
||||
ledc_timer_t led_timer_num; /*!< Select the timer source of channel (0 - 3) */
|
||||
uint32_t led_freq_hz; /*!< LEDC timer frequency (Hz) */
|
||||
int gpio_num; /*!< Optional, < 0 invalid gpio number */
|
||||
} periph_led_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the LED peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_led_init (periph_led_cfg_t *config);
|
||||
/**
|
||||
* @brief Create the LED peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_led_init(periph_led_cfg_t* config);
|
||||
|
||||
/**
|
||||
* @brief Bink LED Peripheral, this function will automatically
|
||||
* configure the gpio_num to control the LED, with `time_on_ms` as the time
|
||||
* (in milliseconds) switch from OFF to ON (or ON if fade is disabled), and
|
||||
* `time_off_ms` as the time (in milliseconds) switch from ON to OFF (or OFF
|
||||
* if fade is disabled). When switching from ON -> OFF and vice versa, the
|
||||
* loop decreases once, and will turn off the effect when the loop is 0. With
|
||||
* a loop value less than 0, the LED effect will loop endlessly.
|
||||
* PERIPH_LED_BLINK_FINISH events will be sent at each end of
|
||||
* loop
|
||||
*
|
||||
* @param[in] periph The LED periph
|
||||
* @param[in] gpio_num The gpio number
|
||||
* @param[in] time_on_ms The time on milliseconds
|
||||
* @param[in] time_off_ms The time off milliseconds
|
||||
* @param[in] fade Fading enabled
|
||||
* @param[in] loop Loop
|
||||
* @param[in] level idle level
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_led_blink (esp_periph_handle_t periph, int gpio_num,
|
||||
int time_on_ms, int time_off_ms, bool fade,
|
||||
int loop, periph_led_idle_level_t level);
|
||||
/**
|
||||
* @brief Bink LED Peripheral, this function will automatically configure
|
||||
* the gpio_num to control the LED, with `time_on_ms` as the time (in
|
||||
* milliseconds) switch from OFF to ON (or ON if fade is disabled), and
|
||||
* `time_off_ms` as the time (in milliseconds) switch from ON to OFF (or OFF if
|
||||
* fade is disabled). When switching from ON -> OFF and vice versa, the loop
|
||||
* decreases once, and will turn off the effect when the loop is 0. With a loop
|
||||
* value less than 0, the LED effect will loop endlessly.
|
||||
* PERIPH_LED_BLINK_FINISH events will be sent at each end of loop
|
||||
*
|
||||
* @param[in] periph The LED periph
|
||||
* @param[in] gpio_num The gpio number
|
||||
* @param[in] time_on_ms The time on milliseconds
|
||||
* @param[in] time_off_ms The time off milliseconds
|
||||
* @param[in] fade Fading enabled
|
||||
* @param[in] loop Loop
|
||||
* @param[in] level idle level
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_led_blink(esp_periph_handle_t periph, int gpio_num,
|
||||
int time_on_ms, int time_off_ms, bool fade, int loop,
|
||||
periph_led_idle_level_t level);
|
||||
|
||||
/**
|
||||
* @brief Stop Blink the LED
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] gpio_num The gpio number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_led_stop (esp_periph_handle_t periph, int gpio_num);
|
||||
/**
|
||||
* @brief Stop Blink the LED
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] gpio_num The gpio number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_led_stop(esp_periph_handle_t periph, int gpio_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,81 +18,75 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SDCARD_DEV_H_
|
||||
#define _SDCARD_DEV_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Peripheral sdcard event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDCARD_STATUS_UNKNOWN, /*!< No event */
|
||||
SDCARD_STATUS_CARD_DETECT_CHANGE, /*!< Detect changes in the card_detect
|
||||
pin */
|
||||
SDCARD_STATUS_MOUNTED, /*!< SDCARD mounted successfully */
|
||||
SDCARD_STATUS_UNMOUNTED, /*!< SDCARD unmounted successfully */
|
||||
SDCARD_STATUS_MOUNT_ERROR, /*!< SDCARD mount error */
|
||||
SDCARD_STATUS_UNMOUNT_ERROR, /*!< SDCARD unmount error */
|
||||
} periph_sdcard_event_id_t;
|
||||
/**
|
||||
* @brief Peripheral sdcard event id
|
||||
*/
|
||||
typedef enum {
|
||||
SDCARD_STATUS_UNKNOWN, /*!< No event */
|
||||
SDCARD_STATUS_CARD_DETECT_CHANGE, /*!< Detect changes in the card_detect pin
|
||||
*/
|
||||
SDCARD_STATUS_MOUNTED, /*!< SDCARD mounted successfully */
|
||||
SDCARD_STATUS_UNMOUNTED, /*!< SDCARD unmounted successfully */
|
||||
SDCARD_STATUS_MOUNT_ERROR, /*!< SDCARD mount error */
|
||||
SDCARD_STATUS_UNMOUNT_ERROR, /*!< SDCARD unmount error */
|
||||
} periph_sdcard_event_id_t;
|
||||
|
||||
/**
|
||||
* @brief SD card mode, SPI, 1-line SD mode, 4-line SD mode
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SD_MODE_SPI = 0x0, /*!< sd_card SPI*/
|
||||
SD_MODE_1_LINE = 0x1, /*!< sd_card 1-line SD mode*/
|
||||
SD_MODE_4_LINE = 0x2, /*!< sd_card 4-line SD mode*/
|
||||
SD_MODE_MAX,
|
||||
} periph_sdcard_mode_t;
|
||||
/**
|
||||
* @brief SD card mode, SPI, 1-line SD mode, 4-line SD mode
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SD_MODE_SPI = 0x0, /*!< sd_card SPI*/
|
||||
SD_MODE_1_LINE = 0x1, /*!< sd_card 1-line SD mode*/
|
||||
SD_MODE_4_LINE = 0x4, /*!< sd_card 4-line SD mode*/
|
||||
SD_MODE_8_LINE = 0x8, /*!< sd_card 8-line SD mode*/
|
||||
SD_MODE_MAX,
|
||||
} periph_sdcard_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The SD Card Peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int card_detect_pin; /*!< Card detect gpio number */
|
||||
const char *root; /*!< Base path for vfs */
|
||||
periph_sdcard_mode_t mode; /*!< card mode*/
|
||||
} periph_sdcard_cfg_t;
|
||||
/**
|
||||
* @brief The SD Card Peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
int card_detect_pin; /*!< Card detect gpio number */
|
||||
const char* root; /*!< Base path for vfs */
|
||||
periph_sdcard_mode_t mode; /*!< card mode*/
|
||||
} periph_sdcard_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the sdcard peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param sdcard_config The sdcard configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_sdcard_init (periph_sdcard_cfg_t *sdcard_config);
|
||||
/**
|
||||
* @brief Create the sdcard peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param sdcard_config The sdcard configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_sdcard_init(periph_sdcard_cfg_t* sdcard_config);
|
||||
|
||||
/**
|
||||
* @brief Check the sdcard is mounted or not.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return SDCARD mounted state
|
||||
*/
|
||||
bool periph_sdcard_is_mounted (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Check the sdcard is mounted or not.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return SDCARD mounted state
|
||||
*/
|
||||
bool periph_sdcard_is_mounted(esp_periph_handle_t periph);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,72 +18,66 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SPIFFS_DEV_H_
|
||||
#define _SPIFFS_DEV_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Peripheral spiffs event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SPIFFS_STATUS_UNKNOWN, /*!< No event */
|
||||
SPIFFS_STATUS_MOUNTED, /*!< SPIFFS mounted successfully */
|
||||
SPIFFS_STATUS_UNMOUNTED, /*!< SPIFFS unmounted successfully */
|
||||
SPIFFS_STATUS_MOUNT_ERROR, /*!< SPIFFS mount error */
|
||||
SPIFFS_STATUS_UNMOUNT_ERROR, /*!< SPIFFS unmount error */
|
||||
} periph_spiffs_event_id_t;
|
||||
/**
|
||||
* @brief Peripheral spiffs event id
|
||||
*/
|
||||
typedef enum {
|
||||
SPIFFS_STATUS_UNKNOWN, /*!< No event */
|
||||
SPIFFS_STATUS_MOUNTED, /*!< SPIFFS mounted successfully */
|
||||
SPIFFS_STATUS_UNMOUNTED, /*!< SPIFFS unmounted successfully */
|
||||
SPIFFS_STATUS_MOUNT_ERROR, /*!< SPIFFS mount error */
|
||||
SPIFFS_STATUS_UNMOUNT_ERROR, /*!< SPIFFS unmount error */
|
||||
} periph_spiffs_event_id_t;
|
||||
|
||||
/**
|
||||
* @brief The SPIFFS Peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *root; /*!< Base path for vfs */
|
||||
const char *partition_label; /*!< Optional, label of SPIFFS partition to
|
||||
use. If set to NULL, first partition with
|
||||
subtype=spiffs will be used. */
|
||||
size_t max_files; /*!< Maximum number of files that could be open at the
|
||||
same time. */
|
||||
bool format_if_mount_failed; /*!< If true, it will format the file system
|
||||
if it fails to mount. */
|
||||
} periph_spiffs_cfg_t;
|
||||
/**
|
||||
* @brief The SPIFFS Peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
const char* root; /*!< Base path for vfs */
|
||||
const char* partition_label; /*!< Optional, label of SPIFFS partition to use.
|
||||
If set to NULL, first partition with
|
||||
subtype=spiffs will be used. */
|
||||
size_t max_files; /*!< Maximum number of files that could be open at the same
|
||||
time. */
|
||||
bool format_if_mount_failed; /*!< If true, it will format the file system if
|
||||
it fails to mount. */
|
||||
} periph_spiffs_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the spiffs peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle created by this function will be automatically
|
||||
* destroyed when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param spiffs_config The spiffs configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_spiffs_init (periph_spiffs_cfg_t *spiffs_config);
|
||||
/**
|
||||
* @brief Create the spiffs peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle created by this function will be automatically
|
||||
* destroyed when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param spiffs_config The spiffs configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_spiffs_init(periph_spiffs_cfg_t* spiffs_config);
|
||||
|
||||
/**
|
||||
* @brief Check if the SPIFFS is mounted or not.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return SPIFFS mounted state
|
||||
*/
|
||||
bool periph_spiffs_is_mounted (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Check if the SPIFFS is mounted or not.
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return SPIFFS mounted state
|
||||
*/
|
||||
bool periph_spiffs_is_mounted(esp_periph_handle_t periph);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,82 +18,74 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TOUCH_DEV_H_
|
||||
#define _TOUCH_DEV_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Touch pad selection
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TOUCH_PAD_SEL0 = BIT (0),
|
||||
TOUCH_PAD_SEL1 = BIT (1),
|
||||
TOUCH_PAD_SEL2 = BIT (2),
|
||||
TOUCH_PAD_SEL3 = BIT (3),
|
||||
TOUCH_PAD_SEL4 = BIT (4),
|
||||
TOUCH_PAD_SEL5 = BIT (5),
|
||||
TOUCH_PAD_SEL6 = BIT (6),
|
||||
TOUCH_PAD_SEL7 = BIT (7),
|
||||
TOUCH_PAD_SEL8 = BIT (8),
|
||||
TOUCH_PAD_SEL9 = BIT (9),
|
||||
} esp_touch_pad_sel_t;
|
||||
/**
|
||||
* @brief Touch pad selection
|
||||
*/
|
||||
typedef enum {
|
||||
TOUCH_PAD_SEL0 = BIT(0),
|
||||
TOUCH_PAD_SEL1 = BIT(1),
|
||||
TOUCH_PAD_SEL2 = BIT(2),
|
||||
TOUCH_PAD_SEL3 = BIT(3),
|
||||
TOUCH_PAD_SEL4 = BIT(4),
|
||||
TOUCH_PAD_SEL5 = BIT(5),
|
||||
TOUCH_PAD_SEL6 = BIT(6),
|
||||
TOUCH_PAD_SEL7 = BIT(7),
|
||||
TOUCH_PAD_SEL8 = BIT(8),
|
||||
TOUCH_PAD_SEL9 = BIT(9),
|
||||
} esp_touch_pad_sel_t;
|
||||
|
||||
/**
|
||||
* @brief The Touch peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int touch_mask; /*!< Touch pad mask using for this Touch peripheral, ex:
|
||||
TOUCH_PAD_SEL0 | TOUCH_PAD_SEL1 */
|
||||
int tap_threshold_percent; /*!< Tap threshold percent, Tap event will be
|
||||
determined if the percentage value is less
|
||||
than the non-touch value */
|
||||
int long_tap_time_ms; /*!< Long tap duration in milliseconds, default is
|
||||
2000ms, PERIPH_TOUCH_LONG_TAP will be occurred if
|
||||
TAP and time hold longer than this value */
|
||||
} periph_touch_cfg_t;
|
||||
/**
|
||||
* @brief The Touch peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
int touch_mask; /*!< Touch pad mask using for this Touch peripheral, ex:
|
||||
TOUCH_PAD_SEL0 | TOUCH_PAD_SEL1 */
|
||||
int tap_threshold_percent; /*!< Tap threshold percent, Tap event will be
|
||||
determined if the percentage value is less than
|
||||
the non-touch value */
|
||||
int long_tap_time_ms; /*!< Long tap duration in milliseconds, default is
|
||||
2000ms, PERIPH_TOUCH_LONG_TAP will be occurred if TAP
|
||||
and time hold longer than this value */
|
||||
} periph_touch_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Peripheral touch event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_TOUCH_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_TOUCH_TAP, /*!< When touch pad is tapped */
|
||||
PERIPH_TOUCH_RELEASE, /*!< When touch pad is released after tap */
|
||||
PERIPH_TOUCH_LONG_TAP, /*!< When touch pad is tapped and held after
|
||||
`long_tap_time_ms` time */
|
||||
PERIPH_TOUCH_LONG_RELEASE, /*!< When touch pad is released after long tap
|
||||
*/
|
||||
} periph_touch_event_id_t;
|
||||
/**
|
||||
* @brief Peripheral touch event id
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_TOUCH_UNCHANGE = 0, /*!< No event */
|
||||
PERIPH_TOUCH_TAP, /*!< When touch pad is tapped */
|
||||
PERIPH_TOUCH_RELEASE, /*!< When touch pad is released after tap */
|
||||
PERIPH_TOUCH_LONG_TAP, /*!< When touch pad is tapped and held after
|
||||
`long_tap_time_ms` time */
|
||||
PERIPH_TOUCH_LONG_RELEASE, /*!< When touch pad is released after long tap */
|
||||
} periph_touch_event_id_t;
|
||||
|
||||
/**
|
||||
* @brief Create the touch peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_touch_init (periph_touch_cfg_t *config);
|
||||
/**
|
||||
* @brief Create the touch peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_touch_init(periph_touch_cfg_t* config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,144 +18,150 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DEV_WIFI_H_
|
||||
#define _DEV_WIFI_H_
|
||||
|
||||
#include "audio_common.h"
|
||||
#include "audio_error.h"
|
||||
#include "esp_peripherals.h"
|
||||
#include "sys/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Peripheral Wi-Fi event id
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_WIFI_UNCHANGE = 0,
|
||||
PERIPH_WIFI_CONNECTING,
|
||||
PERIPH_WIFI_CONNECTED,
|
||||
PERIPH_WIFI_DISCONNECTED,
|
||||
PERIPH_WIFI_SETTING,
|
||||
PERIPH_WIFI_CONFIG_DONE,
|
||||
PERIPH_WIFI_CONFIG_ERROR,
|
||||
PERIPH_WIFI_ERROR,
|
||||
} periph_wifi_state_t;
|
||||
/**
|
||||
* @brief Peripheral Wi-Fi event id
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_WIFI_UNCHANGE = 0,
|
||||
PERIPH_WIFI_CONNECTING,
|
||||
PERIPH_WIFI_CONNECTED,
|
||||
PERIPH_WIFI_DISCONNECTED,
|
||||
PERIPH_WIFI_SETTING,
|
||||
PERIPH_WIFI_CONFIG_DONE,
|
||||
PERIPH_WIFI_CONFIG_ERROR,
|
||||
PERIPH_WIFI_ERROR,
|
||||
} periph_wifi_state_t;
|
||||
|
||||
/**
|
||||
* @brief Wi-Fi setup mode type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
WIFI_CONFIG_ESPTOUCH, /*!< Using smartconfig with ESPTOUCH protocol */
|
||||
WIFI_CONFIG_AIRKISS, /*!< Using smartconfig with AIRKISS protocol */
|
||||
WIFI_CONFIG_ESPTOUCH_AIRKISS, /*!< Using smartconfig with ESPTOUCH_AIRKISS
|
||||
protocol */
|
||||
WIFI_CONFIG_WPS, /*!< Using WPS (not support) */
|
||||
WIFI_CONFIG_BLUEFI, /*!< Using BLUEFI*/
|
||||
WIFI_CONFIG_WEB, /*!< Using HTTP Server (not support) */
|
||||
} periph_wifi_config_mode_t;
|
||||
/**
|
||||
* @brief Wi-Fi setup mode type
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_CONFIG_ESPTOUCH, /*!< Using smartconfig with ESPTOUCH protocol */
|
||||
WIFI_CONFIG_AIRKISS, /*!< Using smartconfig with AIRKISS protocol */
|
||||
WIFI_CONFIG_ESPTOUCH_AIRKISS, /*!< Using smartconfig with ESPTOUCH_AIRKISS
|
||||
protocol */
|
||||
WIFI_CONFIG_WPS, /*!< Using WPS (not support) */
|
||||
WIFI_CONFIG_BLUEFI, /*!< Using BLUEFI*/
|
||||
WIFI_CONFIG_WEB, /*!< Using HTTP Server (not support) */
|
||||
} periph_wifi_config_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The WPA2 enterprise peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool diasble_wpa2_e; /*!< Disable wpa2 enterprise */
|
||||
int eap_method; /*!< TLS: 0, PEAP: 1, TTLS: 2 */
|
||||
char *ca_pem_start; /*!< binary wpa2 ca pem start */
|
||||
char *ca_pem_end; /*!< binary wpa2 ca pem end */
|
||||
char *wpa2_e_cert_start; /*!< binary wpa2 cert start */
|
||||
char *wpa2_e_cert_end; /*!< binary wpa2 cert end */
|
||||
char *wpa2_e_key_start; /*!< binary wpa2 key start */
|
||||
char *wpa2_e_key_end; /*!< binary wpa2 key end */
|
||||
const char *eap_id; /*!< Identity in phase 1 of EAP procedure */
|
||||
const char *eap_username; /*!< Username for EAP method (PEAP and TTLS) */
|
||||
const char *eap_password; /*!< Password for EAP method (PEAP and TTLS) */
|
||||
} periph_wpa2_enterprise_cfg_t;
|
||||
/**
|
||||
* @brief The WPA2 enterprise peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
bool diasble_wpa2_e; /*!< Disable wpa2 enterprise */
|
||||
int eap_method; /*!< TLS: 0, PEAP: 1, TTLS: 2 */
|
||||
char *ca_pem_start; /*!< binary wpa2 ca pem start */
|
||||
char *ca_pem_end; /*!< binary wpa2 ca pem end */
|
||||
char *wpa2_e_cert_start; /*!< binary wpa2 cert start */
|
||||
char *wpa2_e_cert_end; /*!< binary wpa2 cert end */
|
||||
char *wpa2_e_key_start; /*!< binary wpa2 key start */
|
||||
char *wpa2_e_key_end; /*!< binary wpa2 key end */
|
||||
const char *eap_id; /*!< Identity in phase 1 of EAP procedure */
|
||||
const char *eap_username; /*!< Username for EAP method (PEAP and TTLS) */
|
||||
const char *eap_password; /*!< Password for EAP method (PEAP and TTLS) */
|
||||
} periph_wpa2_enterprise_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief The Wi-Fi peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool disable_auto_reconnect; /*!< Disable Wi-Fi auto reconnect */
|
||||
int reconnect_timeout_ms; /*!< The reconnect timeout after disconnected
|
||||
from Wi-Fi network */
|
||||
const char *ssid; /*!< SSID of target AP */
|
||||
const char *password; /*!< password of target AP */
|
||||
periph_wpa2_enterprise_cfg_t wpa2_e_cfg; /*!< wpa2 enterprise config */
|
||||
} periph_wifi_cfg_t;
|
||||
/**
|
||||
* @brief The Wi-Fi peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
bool disable_auto_reconnect; /*!< Disable Wi-Fi auto reconnect */
|
||||
int reconnect_timeout_ms; /*!< The reconnect timeout after disconnected from
|
||||
Wi-Fi network */
|
||||
const char *ssid; /*!< SSID of target AP */
|
||||
const char *password; /*!< password of target AP */
|
||||
periph_wpa2_enterprise_cfg_t wpa2_e_cfg; /*!< wpa2 enterprise config */
|
||||
} periph_wifi_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the wifi peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_wifi_init (periph_wifi_cfg_t *config);
|
||||
/**
|
||||
* @brief Create the wifi peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_wifi_init(periph_wifi_cfg_t *config);
|
||||
|
||||
/**
|
||||
* @brief This function will block current thread (in `tick_to_wait`
|
||||
* tick) and wait until ESP32 connected to the Wi-Fi network, and got ip
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] tick_to_wait The tick to wait
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_wait_for_connected (esp_periph_handle_t periph,
|
||||
TickType_t tick_to_wait);
|
||||
/**
|
||||
* @brief This function will block current thread (in `tick_to_wait` tick)
|
||||
* and wait until ESP32 connected to the Wi-Fi network, and got ip
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] tick_to_wait The tick to wait
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_wait_for_connected(esp_periph_handle_t periph,
|
||||
TickType_t tick_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Check the Wi-Fi connection status
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return Wi-Fi network status
|
||||
*/
|
||||
periph_wifi_state_t periph_wifi_is_connected (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Check the Wi-Fi connection status
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return Wi-Fi network status
|
||||
*/
|
||||
periph_wifi_state_t periph_wifi_is_connected(esp_periph_handle_t periph);
|
||||
|
||||
/**
|
||||
* @brief Start Wi-Fi network setup in `mode`
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] mode The mode
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_config_start (esp_periph_handle_t periph,
|
||||
periph_wifi_config_mode_t mode);
|
||||
/**
|
||||
* @brief Set Wi-Fi listen interval for ESP32 station to receive beacon
|
||||
*
|
||||
* @param[in] periph The wifi periph
|
||||
* @param[in] interval listen interval. units: AP beacon intervals(see BcnInt,
|
||||
* default: 100ms)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_wifi_set_listen_interval(esp_periph_handle_t periph,
|
||||
int interval);
|
||||
|
||||
/**
|
||||
* @brief Wait for Wi-Fi setup done
|
||||
* @param[in] periph The periph
|
||||
* @param[in] tick_to_wait The tick to wait
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_config_wait_done (esp_periph_handle_t periph,
|
||||
TickType_t tick_to_wait);
|
||||
/**
|
||||
* @brief Start Wi-Fi network setup in `mode`
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
* @param[in] mode The mode
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_config_start(esp_periph_handle_t periph,
|
||||
periph_wifi_config_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Wait for Wi-Fi setup done
|
||||
* @param[in] periph The periph
|
||||
* @param[in] tick_to_wait The tick to wait
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_wifi_config_wait_done(esp_periph_handle_t periph,
|
||||
TickType_t tick_to_wait);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
|
||||
* which case, it is free of charge, to any person obtaining a copy of this
|
||||
* software and associated documentation files (the "Software"), to deal in the
|
||||
* Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
@@ -18,9 +18,9 @@
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _PERIPH_WS2812_DRIVER_H
|
||||
@@ -29,98 +29,91 @@
|
||||
#include "esp_peripherals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The RGB peripheral value
|
||||
*/
|
||||
typedef uint32_t periph_rgb_value;
|
||||
/**
|
||||
* @brief The RGB peripheral value
|
||||
*/
|
||||
typedef uint32_t periph_rgb_value;
|
||||
|
||||
#define make_rgb_value(x, y, z) (((int)(z) << 16) + ((int)(y) << 8) + (x))
|
||||
|
||||
#define LED2812_COLOR_BLACK make_rgb_value (0, 0, 0)
|
||||
#define LED2812_COLOR_BLUE make_rgb_value (0, 0, 255)
|
||||
#define LED2812_COLOR_GREEN make_rgb_value (0, 255, 0)
|
||||
#define LED2812_COLOR_CYAN make_rgb_value (0, 255, 255)
|
||||
#define LED2812_COLOR_RED make_rgb_value (255, 0, 0)
|
||||
#define LED2812_COLOR_PURPLE make_rgb_value (255, 0, 255)
|
||||
#define LED2812_COLOR_YELLOW make_rgb_value (255, 255, 0)
|
||||
#define LED2812_COLOR_WHITE make_rgb_value (255, 255, 255)
|
||||
#define LED2812_COLOR_ORANGE make_rgb_value (255, 165, 0)
|
||||
#define LED2812_COLOR_BLACK make_rgb_value(0, 0, 0)
|
||||
#define LED2812_COLOR_BLUE make_rgb_value(0, 0, 255)
|
||||
#define LED2812_COLOR_GREEN make_rgb_value(0, 255, 0)
|
||||
#define LED2812_COLOR_CYAN make_rgb_value(0, 255, 255)
|
||||
#define LED2812_COLOR_RED make_rgb_value(255, 0, 0)
|
||||
#define LED2812_COLOR_PURPLE make_rgb_value(255, 0, 255)
|
||||
#define LED2812_COLOR_YELLOW make_rgb_value(255, 255, 0)
|
||||
#define LED2812_COLOR_WHITE make_rgb_value(255, 255, 255)
|
||||
#define LED2812_COLOR_ORANGE make_rgb_value(255, 165, 0)
|
||||
|
||||
/**
|
||||
* @brief The ws2812 peripheral configuration
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int gpio_num; /*!< The GPIO number of ws2812*/
|
||||
int led_num; /*!< The number of ws2812 */
|
||||
} periph_ws2812_cfg_t;
|
||||
/**
|
||||
* @brief The ws2812 peripheral configuration
|
||||
*/
|
||||
typedef struct {
|
||||
int gpio_num; /*!< The GPIO number of ws2812*/
|
||||
int led_num; /*!< The number of ws2812 */
|
||||
} periph_ws2812_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief The periph ws2812 mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PERIPH_WS2812_BLINK,
|
||||
PERIPH_WS2812_FADE,
|
||||
PERIPH_WS2812_ONE,
|
||||
} periph_ws2812_mode_t;
|
||||
/**
|
||||
* @brief The periph ws2812 mode
|
||||
*/
|
||||
typedef enum {
|
||||
PERIPH_WS2812_BLINK,
|
||||
PERIPH_WS2812_FADE,
|
||||
PERIPH_WS2812_ONE,
|
||||
} periph_ws2812_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The periph ws2812 control config
|
||||
*/
|
||||
typedef struct periph_ws2812_ctrl_cfg
|
||||
{
|
||||
periph_rgb_value color; /*!< The RGB value */
|
||||
uint32_t
|
||||
time_on_ms; /*!< The time on milliseconds, suggest min is 100 ms */
|
||||
uint32_t
|
||||
time_off_ms; /*!< The time off milliseconds, suggest min is 100 ms */
|
||||
uint32_t loop; /*!< The times offloop */
|
||||
periph_ws2812_mode_t
|
||||
mode; /*!< ws2812 mode (setting color, blink or fade) */
|
||||
} periph_ws2812_ctrl_cfg_t;
|
||||
/**
|
||||
* @brief The periph ws2812 control config
|
||||
*/
|
||||
typedef struct periph_ws2812_ctrl_cfg {
|
||||
periph_rgb_value color; /*!< The RGB value */
|
||||
uint32_t time_on_ms; /*!< The time on milliseconds, suggest min is 100 ms */
|
||||
uint32_t time_off_ms; /*!< The time off milliseconds, suggest min is 100 ms */
|
||||
uint32_t loop; /*!< The times offloop */
|
||||
periph_ws2812_mode_t mode; /*!< ws2812 mode (setting color, blink or fade) */
|
||||
} periph_ws2812_ctrl_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief Create the ws2812 peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_ws2812_init (periph_ws2812_cfg_t *config);
|
||||
/**
|
||||
* @brief Create the ws2812 peripheral handle for esp_peripherals
|
||||
*
|
||||
* @note The handle was created by this function automatically destroy
|
||||
* when `esp_periph_destroy` is called
|
||||
*
|
||||
* @param config The configuration
|
||||
*
|
||||
* @return The esp peripheral handle
|
||||
*/
|
||||
esp_periph_handle_t periph_ws2812_init(periph_ws2812_cfg_t *config);
|
||||
|
||||
/**
|
||||
* @brief Control ws2812 Peripheral
|
||||
*
|
||||
* @param[in] periph The ws2812 periph
|
||||
* @param[in] control_cfg The ws2812 color config
|
||||
* @param[in] ctx The ctx
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_ws2812_control (esp_periph_handle_t periph,
|
||||
periph_ws2812_ctrl_cfg_t *control_cfg,
|
||||
void *ctx);
|
||||
/**
|
||||
* @brief Control ws2812 Peripheral
|
||||
*
|
||||
* @param[in] periph The ws2812 periph
|
||||
* @param[in] control_cfg The ws2812 color config
|
||||
* @param[in] ctx The ctx
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_ws2812_control(esp_periph_handle_t periph,
|
||||
periph_ws2812_ctrl_cfg_t *control_cfg,
|
||||
void *ctx);
|
||||
|
||||
/**
|
||||
* @brief Stop ws2812
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_ws2812_stop (esp_periph_handle_t periph);
|
||||
/**
|
||||
* @brief Stop ws2812
|
||||
*
|
||||
* @param[in] periph The periph
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t periph_ws2812_stop(esp_periph_handle_t periph);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user