mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-30 12:30:59 +02:00
IDF master c13afea63 (#5214)
esp-dsp: master 7cc5073 esp-face: master 420fc7e esp-rainmaker: f1b82c7 esp32-camera: master 6f8489e esp_littlefs: master b58f00c
This commit is contained in:
@ -1,16 +1,8 @@
|
||||
// Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ESP_APP_TRACE_H_
|
||||
#define ESP_APP_TRACE_H_
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ESP_APP_TRACE_UTIL_H_
|
||||
#define ESP_APP_TRACE_UTIL_H_
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ESP_SYSVIEW_TRACE_H_
|
||||
#define ESP_SYSVIEW_TRACE_H_
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _OTA_OPS_H
|
||||
#define _OTA_OPS_H
|
||||
|
@ -358,33 +358,37 @@ extern "C" {
|
||||
// Application API (Multiple Interfaces)
|
||||
// CFG_TUD_AUDIO > 1
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_audio_n_mounted (uint8_t itf);
|
||||
bool tud_audio_n_mounted (uint8_t func_id);
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
uint16_t tud_audio_n_available (uint8_t itf);
|
||||
uint16_t tud_audio_n_read (uint8_t itf, void* buffer, uint16_t bufsize);
|
||||
bool tud_audio_n_clear_ep_out_ff (uint8_t itf); // Delete all content in the EP OUT FIFO
|
||||
uint16_t tud_audio_n_available (uint8_t func_id);
|
||||
uint16_t tud_audio_n_read (uint8_t func_id, void* buffer, uint16_t bufsize);
|
||||
bool tud_audio_n_clear_ep_out_ff (uint8_t func_id); // Delete all content in the EP OUT FIFO
|
||||
tu_fifo_t* tud_audio_n_get_ep_out_ff (uint8_t func_id);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
bool tud_audio_n_clear_rx_support_ff (uint8_t itf, uint8_t channelId); // Delete all content in the support RX FIFOs
|
||||
uint16_t tud_audio_n_available_support_ff (uint8_t itf, uint8_t channelId);
|
||||
uint16_t tud_audio_n_read_support_ff (uint8_t itf, uint8_t channelId, void* buffer, uint16_t bufsize);
|
||||
bool tud_audio_n_clear_rx_support_ff (uint8_t func_id, uint8_t ff_idx); // Delete all content in the support RX FIFOs
|
||||
uint16_t tud_audio_n_available_support_ff (uint8_t func_id, uint8_t ff_idx);
|
||||
uint16_t tud_audio_n_read_support_ff (uint8_t func_id, uint8_t ff_idx, void* buffer, uint16_t bufsize);
|
||||
tu_fifo_t* tud_audio_n_get_rx_support_ff (uint8_t func_id, uint8_t ff_idx);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
uint16_t tud_audio_n_write (uint8_t itf, const void * data, uint16_t len);
|
||||
bool tud_audio_n_clear_ep_in_ff (uint8_t itf); // Delete all content in the EP IN FIFO
|
||||
uint16_t tud_audio_n_write (uint8_t func_id, const void * data, uint16_t len);
|
||||
bool tud_audio_n_clear_ep_in_ff (uint8_t func_id); // Delete all content in the EP IN FIFO
|
||||
tu_fifo_t* tud_audio_n_get_ep_in_ff (uint8_t func_id);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
uint16_t tud_audio_n_flush_tx_support_ff (uint8_t itf); // Force all content in the support TX FIFOs to be written into EP SW FIFO
|
||||
bool tud_audio_n_clear_tx_support_ff (uint8_t itf, uint8_t channelId);
|
||||
uint16_t tud_audio_n_write_support_ff (uint8_t itf, uint8_t channelId, const void * data, uint16_t len);
|
||||
uint16_t tud_audio_n_flush_tx_support_ff (uint8_t func_id); // Force all content in the support TX FIFOs to be written into EP SW FIFO
|
||||
bool tud_audio_n_clear_tx_support_ff (uint8_t func_id, uint8_t ff_idx);
|
||||
uint16_t tud_audio_n_write_support_ff (uint8_t func_id, uint8_t ff_idx, const void * data, uint16_t len);
|
||||
tu_fifo_t* tud_audio_n_get_tx_support_ff (uint8_t func_id, uint8_t ff_idx);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
uint16_t tud_audio_int_ctr_n_write (uint8_t itf, uint8_t const* buffer, uint16_t len);
|
||||
uint16_t tud_audio_int_ctr_n_write (uint8_t func_id, uint8_t const* buffer, uint16_t len);
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -399,12 +403,14 @@ static inline bool tud_audio_mounted (void);
|
||||
static inline uint16_t tud_audio_available (void);
|
||||
static inline bool tud_audio_clear_ep_out_ff (void); // Delete all content in the EP OUT FIFO
|
||||
static inline uint16_t tud_audio_read (void* buffer, uint16_t bufsize);
|
||||
static inline tu_fifo_t* tud_audio_get_ep_out_ff (void);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
static inline bool tud_audio_clear_rx_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_available_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_read_support_ff (uint8_t channelId, void* buffer, uint16_t bufsize);
|
||||
static inline bool tud_audio_clear_rx_support_ff (uint8_t ff_idx);
|
||||
static inline uint16_t tud_audio_available_support_ff (uint8_t ff_idx);
|
||||
static inline uint16_t tud_audio_read_support_ff (uint8_t ff_idx, void* buffer, uint16_t bufsize);
|
||||
static inline tu_fifo_t* tud_audio_get_rx_support_ff (uint8_t ff_idx);
|
||||
#endif
|
||||
|
||||
// TX API
|
||||
@ -412,12 +418,14 @@ static inline uint16_t tud_audio_read_support_ff (uint8_t channelId,
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
static inline uint16_t tud_audio_write (const void * data, uint16_t len);
|
||||
static inline bool tud_audio_clear_ep_in_ff (void);
|
||||
static inline tu_fifo_t* tud_audio_get_ep_in_ff (void);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
static inline uint16_t tud_audio_flush_tx_support_ff (void);
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_write_support_ff (uint8_t channelId, const void * data, uint16_t len);
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff (uint8_t ff_idx);
|
||||
static inline uint16_t tud_audio_write_support_ff (uint8_t ff_idx, const void * data, uint16_t len);
|
||||
static inline tu_fifo_t* tud_audio_get_tx_support_ff (uint8_t ff_idx);
|
||||
#endif
|
||||
|
||||
// INT CTR API
|
||||
@ -439,13 +447,13 @@ bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_req
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_pre_load_cb(uint8_t rhport, uint8_t itf, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_post_load_cb(uint8_t rhport, uint16_t n_bytes_copied, uint8_t itf, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_pre_load_cb(uint8_t rhport, uint8_t func_id, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_post_load_cb(uint8_t rhport, uint16_t n_bytes_copied, uint8_t func_id, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_pre_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t itf, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_post_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t itf, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_pre_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_post_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
|
||||
@ -454,7 +462,7 @@ TU_ATTR_WEAK bool tud_audio_fb_done_cb(uint8_t rhport);
|
||||
// Value will be corrected for FS to 10.14 format automatically.
|
||||
// (see Universal Serial Bus Specification Revision 2.0 5.12.4.2).
|
||||
// Feedback value will be sent at FB endpoint interval till it's changed.
|
||||
bool tud_audio_n_fb_set(uint8_t itf, uint32_t feedback);
|
||||
bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback);
|
||||
static inline bool tud_audio_fb_set(uint32_t feedback);
|
||||
#endif
|
||||
|
||||
@ -514,23 +522,33 @@ static inline bool tud_audio_clear_ep_out_ff(void)
|
||||
return tud_audio_n_clear_ep_out_ff(0);
|
||||
}
|
||||
|
||||
static inline tu_fifo_t* tud_audio_get_ep_out_ff(void)
|
||||
{
|
||||
return tud_audio_n_get_ep_out_ff(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
|
||||
static inline bool tud_audio_clear_rx_support_ff(uint8_t channelId)
|
||||
static inline bool tud_audio_clear_rx_support_ff(uint8_t ff_idx)
|
||||
{
|
||||
return tud_audio_n_clear_rx_support_ff(0, channelId);
|
||||
return tud_audio_n_clear_rx_support_ff(0, ff_idx);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_available_support_ff(uint8_t channelId)
|
||||
static inline uint16_t tud_audio_available_support_ff(uint8_t ff_idx)
|
||||
{
|
||||
return tud_audio_n_available_support_ff(0, channelId);
|
||||
return tud_audio_n_available_support_ff(0, ff_idx);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_read_support_ff(uint8_t channelId, void* buffer, uint16_t bufsize)
|
||||
static inline uint16_t tud_audio_read_support_ff(uint8_t ff_idx, void* buffer, uint16_t bufsize)
|
||||
{
|
||||
return tud_audio_n_read_support_ff(0, channelId, buffer, bufsize);
|
||||
return tud_audio_n_read_support_ff(0, ff_idx, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline tu_fifo_t* tud_audio_get_rx_support_ff(uint8_t ff_idx)
|
||||
{
|
||||
return tud_audio_n_get_rx_support_ff(0, ff_idx);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -549,6 +567,11 @@ static inline bool tud_audio_clear_ep_in_ff(void)
|
||||
return tud_audio_n_clear_ep_in_ff(0);
|
||||
}
|
||||
|
||||
static inline tu_fifo_t* tud_audio_get_ep_in_ff(void)
|
||||
{
|
||||
return tud_audio_n_get_ep_in_ff(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
@ -558,14 +581,19 @@ static inline uint16_t tud_audio_flush_tx_support_ff(void)
|
||||
return tud_audio_n_flush_tx_support_ff(0);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff(uint8_t channelId)
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff(uint8_t ff_idx)
|
||||
{
|
||||
return tud_audio_n_clear_tx_support_ff(0, channelId);
|
||||
return tud_audio_n_clear_tx_support_ff(0, ff_idx);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_write_support_ff(uint8_t channelId, const void * data, uint16_t len)
|
||||
static inline uint16_t tud_audio_write_support_ff(uint8_t ff_idx, const void * data, uint16_t len)
|
||||
{
|
||||
return tud_audio_n_write_support_ff(0, channelId, data, len);
|
||||
return tud_audio_n_write_support_ff(0, ff_idx, data, len);
|
||||
}
|
||||
|
||||
static inline tu_fifo_t* tud_audio_get_tx_support_ff(uint8_t ff_idx)
|
||||
{
|
||||
return tud_audio_n_get_tx_support_ff(0, ff_idx);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ int32_t tud_cdc_n_read_char (uint8_t itf);
|
||||
void tud_cdc_n_read_flush (uint8_t itf);
|
||||
|
||||
// Get a byte from FIFO at the specified position without removing it
|
||||
bool tud_cdc_n_peek (uint8_t itf, int pos, uint8_t* u8);
|
||||
bool tud_cdc_n_peek (uint8_t itf, uint8_t* u8);
|
||||
|
||||
// Write bytes to TX FIFO, data may remain in the FIFO for a while
|
||||
uint32_t tud_cdc_n_write (uint8_t itf, void const* buffer, uint32_t bufsize);
|
||||
@ -117,7 +117,7 @@ static inline uint32_t tud_cdc_available (void);
|
||||
static inline int32_t tud_cdc_read_char (void);
|
||||
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize);
|
||||
static inline void tud_cdc_read_flush (void);
|
||||
static inline bool tud_cdc_peek (int pos, uint8_t* u8);
|
||||
static inline bool tud_cdc_peek (uint8_t* u8);
|
||||
|
||||
static inline uint32_t tud_cdc_write_char (char ch);
|
||||
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize);
|
||||
@ -207,9 +207,9 @@ static inline void tud_cdc_read_flush (void)
|
||||
tud_cdc_n_read_flush(0);
|
||||
}
|
||||
|
||||
static inline bool tud_cdc_peek (int pos, uint8_t* u8)
|
||||
static inline bool tud_cdc_peek (uint8_t* u8)
|
||||
{
|
||||
return tud_cdc_n_peek(0, pos, u8);
|
||||
return tud_cdc_n_peek(0, u8);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_cdc_write_char (char ch)
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 XMOS LIMITED
|
||||
*
|
||||
* Permission is hereby granted, 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_DFU_H_
|
||||
#define _TUSB_DFU_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Common Definitions
|
||||
//--------------------------------------------------------------------+
|
||||
// DFU Protocol
|
||||
typedef enum
|
||||
{
|
||||
DFU_PROTOCOL_RT = 0x01,
|
||||
DFU_PROTOCOL_DFU = 0x02,
|
||||
} dfu_protocol_type_t;
|
||||
|
||||
// DFU Descriptor Type
|
||||
typedef enum
|
||||
{
|
||||
DFU_DESC_FUNCTIONAL = 0x21,
|
||||
} dfu_descriptor_type_t;
|
||||
|
||||
// DFU Requests
|
||||
typedef enum {
|
||||
DFU_REQUEST_DETACH = 0,
|
||||
DFU_REQUEST_DNLOAD = 1,
|
||||
DFU_REQUEST_UPLOAD = 2,
|
||||
DFU_REQUEST_GETSTATUS = 3,
|
||||
DFU_REQUEST_CLRSTATUS = 4,
|
||||
DFU_REQUEST_GETSTATE = 5,
|
||||
DFU_REQUEST_ABORT = 6,
|
||||
} dfu_requests_t;
|
||||
|
||||
// DFU States
|
||||
typedef enum {
|
||||
APP_IDLE = 0,
|
||||
APP_DETACH = 1,
|
||||
DFU_IDLE = 2,
|
||||
DFU_DNLOAD_SYNC = 3,
|
||||
DFU_DNBUSY = 4,
|
||||
DFU_DNLOAD_IDLE = 5,
|
||||
DFU_MANIFEST_SYNC = 6,
|
||||
DFU_MANIFEST = 7,
|
||||
DFU_MANIFEST_WAIT_RESET = 8,
|
||||
DFU_UPLOAD_IDLE = 9,
|
||||
DFU_ERROR = 10,
|
||||
} dfu_state_t;
|
||||
|
||||
// DFU Status
|
||||
typedef enum {
|
||||
DFU_STATUS_OK = 0x00,
|
||||
DFU_STATUS_ERRTARGET = 0x01,
|
||||
DFU_STATUS_ERRFILE = 0x02,
|
||||
DFU_STATUS_ERRWRITE = 0x03,
|
||||
DFU_STATUS_ERRERASE = 0x04,
|
||||
DFU_STATUS_ERRCHECK_ERASED = 0x05,
|
||||
DFU_STATUS_ERRPROG = 0x06,
|
||||
DFU_STATUS_ERRVERIFY = 0x07,
|
||||
DFU_STATUS_ERRADDRESS = 0x08,
|
||||
DFU_STATUS_ERRNOTDONE = 0x09,
|
||||
DFU_STATUS_ERRFIRMWARE = 0x0A,
|
||||
DFU_STATUS_ERRVENDOR = 0x0B,
|
||||
DFU_STATUS_ERRUSBR = 0x0C,
|
||||
DFU_STATUS_ERRPOR = 0x0D,
|
||||
DFU_STATUS_ERRUNKNOWN = 0x0E,
|
||||
DFU_STATUS_ERRSTALLEDPKT = 0x0F,
|
||||
} dfu_device_status_t;
|
||||
|
||||
#define DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK (1 << 0)
|
||||
#define DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK (1 << 1)
|
||||
#define DFU_FUNC_ATTR_MANIFESTATION_TOLERANT_BITMASK (1 << 2)
|
||||
#define DFU_FUNC_ATTR_WILL_DETACH_BITMASK (1 << 3)
|
||||
|
||||
// DFU Status Request Payload
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bStatus;
|
||||
uint8_t bwPollTimeout[3];
|
||||
uint8_t bState;
|
||||
uint8_t iString;
|
||||
} dfu_status_req_payload_t;
|
||||
|
||||
TU_VERIFY_STATIC( sizeof(dfu_status_req_payload_t) == 6, "size is not correct");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_DFU_H_ */
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 XMOS LIMITED
|
||||
*
|
||||
* Permission is hereby granted, 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_DFU_DEVICE_H_
|
||||
#define _TUSB_DFU_DEVICE_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "device/usbd.h"
|
||||
#include "dfu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
// Invoked during DFU_MANIFEST_SYNC get status request to check if firmware
|
||||
// is valid
|
||||
bool tud_dfu_firmware_valid_check_cb(void);
|
||||
|
||||
// Invoked when a DFU_DNLOAD request is received
|
||||
// This callback takes the wBlockNum chunk of length length and provides it
|
||||
// to the application at the data pointer. This data is only valid for this
|
||||
// call, so the app must use it not or copy it.
|
||||
void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t length);
|
||||
|
||||
// Must be called when the application is done using the last block of data
|
||||
// provided by tud_dfu_req_dnload_data_cb
|
||||
void tud_dfu_dnload_complete(void);
|
||||
|
||||
// Invoked during the last DFU_DNLOAD request, signifying that the host believes
|
||||
// it is done transmitting data.
|
||||
// Return true if the application agrees there is no more data
|
||||
// Return false if the device disagrees, which will stall the pipe, and the Host
|
||||
// should initiate a recovery procedure
|
||||
bool tud_dfu_device_data_done_check_cb(void);
|
||||
|
||||
// Invoked when the Host has terminated a download or upload transfer
|
||||
TU_ATTR_WEAK void tud_dfu_abort_cb(void);
|
||||
|
||||
// Invoked when a DFU_UPLOAD request is received
|
||||
// This callback must populate data with up to length bytes
|
||||
// Return the number of bytes to write
|
||||
uint16_t tud_dfu_req_upload_data_cb(uint16_t block_num, uint8_t* data, uint16_t length);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void dfu_moded_init(void);
|
||||
void dfu_moded_reset(uint8_t rhport);
|
||||
uint16_t dfu_moded_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_DFU_MODE_DEVICE_H_ */
|
@ -29,36 +29,17 @@
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "device/usbd.h"
|
||||
#include "dfu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Common Definitions
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// DFU Protocol
|
||||
typedef enum
|
||||
{
|
||||
DFU_PROTOCOL_RT = 1,
|
||||
DFU_PROTOCOL_DFU = 2,
|
||||
} dfu_protocol_type_t;
|
||||
|
||||
// DFU Descriptor Type
|
||||
typedef enum
|
||||
{
|
||||
DFU_DESC_FUNCTIONAL = 0x21,
|
||||
} dfu_descriptor_type_t;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received new data
|
||||
TU_ATTR_WEAK void tud_dfu_runtime_reboot_to_dfu_cb(void);
|
||||
// Invoked when a DFU_DETACH request is received and bitWillDetach is set
|
||||
void tud_dfu_runtime_reboot_to_dfu_cb(void);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
@ -67,7 +48,6 @@ void dfu_rtd_init(void);
|
||||
void dfu_rtd_reset(uint8_t rhport);
|
||||
uint16_t dfu_rtd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
bool dfu_rtd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ typedef enum
|
||||
{
|
||||
HID_SUBCLASS_NONE = 0, ///< No Subclass
|
||||
HID_SUBCLASS_BOOT = 1 ///< Boot Interface Subclass
|
||||
}hid_subclass_type_t;
|
||||
}hid_subclass_enum_t;
|
||||
|
||||
/// HID Protocol
|
||||
/// HID Interface Protocol
|
||||
typedef enum
|
||||
{
|
||||
HID_PROTOCOL_NONE = 0, ///< None
|
||||
HID_PROTOCOL_KEYBOARD = 1, ///< Keyboard
|
||||
HID_PROTOCOL_MOUSE = 2 ///< Mouse
|
||||
}hid_protocol_type_t;
|
||||
HID_ITF_PROTOCOL_NONE = 0, ///< None
|
||||
HID_ITF_PROTOCOL_KEYBOARD = 1, ///< Keyboard
|
||||
HID_ITF_PROTOCOL_MOUSE = 2 ///< Mouse
|
||||
}hid_interface_protocol_enum_t;
|
||||
|
||||
/// HID Descriptor Type
|
||||
typedef enum
|
||||
@ -78,7 +78,7 @@ typedef enum
|
||||
HID_DESC_TYPE_HID = 0x21, ///< HID Descriptor
|
||||
HID_DESC_TYPE_REPORT = 0x22, ///< Report Descriptor
|
||||
HID_DESC_TYPE_PHYSICAL = 0x23 ///< Physical Descriptor
|
||||
}hid_descriptor_type_t;
|
||||
}hid_descriptor_enum_t;
|
||||
|
||||
/// HID Request Report Type
|
||||
typedef enum
|
||||
@ -98,9 +98,9 @@ typedef enum
|
||||
HID_REQ_CONTROL_SET_REPORT = 0x09, ///< Set Report
|
||||
HID_REQ_CONTROL_SET_IDLE = 0x0a, ///< Set Idle
|
||||
HID_REQ_CONTROL_SET_PROTOCOL = 0x0b ///< Set Protocol
|
||||
}hid_request_type_t;
|
||||
}hid_request_enum_t;
|
||||
|
||||
/// HID Country Code
|
||||
/// HID Local Code
|
||||
typedef enum
|
||||
{
|
||||
HID_LOCAL_NotSupported = 0 , ///< NotSupported
|
||||
@ -139,7 +139,14 @@ typedef enum
|
||||
HID_LOCAL_US , ///< US
|
||||
HID_LOCAL_Yugoslavia , ///< Yugoslavia
|
||||
HID_LOCAL_Turkish_F ///< Turkish-F
|
||||
} hid_country_code_t;
|
||||
} hid_local_enum_t;
|
||||
|
||||
// HID protocol value used by GetProtocol / SetProtocol
|
||||
typedef enum
|
||||
{
|
||||
HID_PROTOCOL_BOOT = 0,
|
||||
HID_PROTOCOL_REPORT = 1
|
||||
} hid_protocol_mode_enum_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
@ -479,6 +486,7 @@ typedef enum
|
||||
//--------------------------------------------------------------------+
|
||||
// REPORT DESCRIPTOR
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- ITEM & TAG -------------//
|
||||
#define HID_REPORT_DATA_0(data)
|
||||
#define HID_REPORT_DATA_1(data) , data
|
||||
@ -488,18 +496,31 @@ typedef enum
|
||||
#define HID_REPORT_ITEM(data, tag, type, size) \
|
||||
(((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data)
|
||||
|
||||
#define RI_TYPE_MAIN 0
|
||||
#define RI_TYPE_GLOBAL 1
|
||||
#define RI_TYPE_LOCAL 2
|
||||
// Report Item Types
|
||||
enum {
|
||||
RI_TYPE_MAIN = 0,
|
||||
RI_TYPE_GLOBAL = 1,
|
||||
RI_TYPE_LOCAL = 2
|
||||
};
|
||||
|
||||
//------------- MAIN ITEMS 6.2.2.4 -------------//
|
||||
#define HID_INPUT(x) HID_REPORT_ITEM(x, 8, RI_TYPE_MAIN, 1)
|
||||
#define HID_OUTPUT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_MAIN, 1)
|
||||
#define HID_COLLECTION(x) HID_REPORT_ITEM(x, 10, RI_TYPE_MAIN, 1)
|
||||
#define HID_FEATURE(x) HID_REPORT_ITEM(x, 11, RI_TYPE_MAIN, 1)
|
||||
#define HID_COLLECTION_END HID_REPORT_ITEM(x, 12, RI_TYPE_MAIN, 0)
|
||||
//------------- Main Items - HID 1.11 section 6.2.2.4 -------------//
|
||||
|
||||
//------------- INPUT, OUTPUT, FEATURE 6.2.2.5 -------------//
|
||||
// Report Item Main group
|
||||
enum {
|
||||
RI_MAIN_INPUT = 8,
|
||||
RI_MAIN_OUTPUT = 9,
|
||||
RI_MAIN_COLLECTION = 10,
|
||||
RI_MAIN_FEATURE = 11,
|
||||
RI_MAIN_COLLECTION_END = 12
|
||||
};
|
||||
|
||||
#define HID_INPUT(x) HID_REPORT_ITEM(x, RI_MAIN_INPUT , RI_TYPE_MAIN, 1)
|
||||
#define HID_OUTPUT(x) HID_REPORT_ITEM(x, RI_MAIN_OUTPUT , RI_TYPE_MAIN, 1)
|
||||
#define HID_COLLECTION(x) HID_REPORT_ITEM(x, RI_MAIN_COLLECTION , RI_TYPE_MAIN, 1)
|
||||
#define HID_FEATURE(x) HID_REPORT_ITEM(x, RI_MAIN_FEATURE , RI_TYPE_MAIN, 1)
|
||||
#define HID_COLLECTION_END HID_REPORT_ITEM(x, RI_MAIN_COLLECTION_END, RI_TYPE_MAIN, 0)
|
||||
|
||||
//------------- Input, Output, Feature - HID 1.11 section 6.2.2.5 -------------//
|
||||
#define HID_DATA (0<<0)
|
||||
#define HID_CONSTANT (1<<0)
|
||||
|
||||
@ -527,7 +548,7 @@ typedef enum
|
||||
#define HID_BITFIELD (0<<8)
|
||||
#define HID_BUFFERED_BYTES (1<<8)
|
||||
|
||||
//------------- COLLECTION ITEM 6.2.2.6 -------------//
|
||||
//------------- Collection Item - HID 1.11 section 6.2.2.6 -------------//
|
||||
enum {
|
||||
HID_COLLECTION_PHYSICAL = 0,
|
||||
HID_COLLECTION_APPLICATION,
|
||||
@ -538,49 +559,81 @@ enum {
|
||||
HID_COLLECTION_USAGE_MODIFIER
|
||||
};
|
||||
|
||||
//------------- GLOBAL ITEMS 6.2.2.7 -------------//
|
||||
#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, n)
|
||||
//------------- Global Items - HID 1.11 section 6.2.2.7 -------------//
|
||||
|
||||
#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, n)
|
||||
// Report Item Global group
|
||||
enum {
|
||||
RI_GLOBAL_USAGE_PAGE = 0,
|
||||
RI_GLOBAL_LOGICAL_MIN = 1,
|
||||
RI_GLOBAL_LOGICAL_MAX = 2,
|
||||
RI_GLOBAL_PHYSICAL_MIN = 3,
|
||||
RI_GLOBAL_PHYSICAL_MAX = 4,
|
||||
RI_GLOBAL_UNIT_EXPONENT = 5,
|
||||
RI_GLOBAL_UNIT = 6,
|
||||
RI_GLOBAL_REPORT_SIZE = 7,
|
||||
RI_GLOBAL_REPORT_ID = 8,
|
||||
RI_GLOBAL_REPORT_COUNT = 9,
|
||||
RI_GLOBAL_PUSH = 10,
|
||||
RI_GLOBAL_POP = 11
|
||||
};
|
||||
|
||||
#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, n)
|
||||
#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, n)
|
||||
#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, n)
|
||||
#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, n)
|
||||
#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_UNIT(x) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, n)
|
||||
#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, n)
|
||||
#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, 1),
|
||||
#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, n),
|
||||
#define HID_UNIT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, n)
|
||||
#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_PUSH HID_REPORT_ITEM(x, 10, RI_TYPE_GLOBAL, 0)
|
||||
#define HID_POP HID_REPORT_ITEM(x, 11, RI_TYPE_GLOBAL, 0)
|
||||
#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, 1),
|
||||
#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, n),
|
||||
|
||||
#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, 1)
|
||||
#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, n)
|
||||
|
||||
#define HID_PUSH HID_REPORT_ITEM(x, RI_GLOBAL_PUSH, RI_TYPE_GLOBAL, 0)
|
||||
#define HID_POP HID_REPORT_ITEM(x, RI_GLOBAL_POP, RI_TYPE_GLOBAL, 0)
|
||||
|
||||
//------------- LOCAL ITEMS 6.2.2.8 -------------//
|
||||
#define HID_USAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, n)
|
||||
|
||||
#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, n)
|
||||
enum {
|
||||
RI_LOCAL_USAGE = 0,
|
||||
RI_LOCAL_USAGE_MIN = 1,
|
||||
RI_LOCAL_USAGE_MAX = 2,
|
||||
RI_LOCAL_DESIGNATOR_INDEX = 3,
|
||||
RI_LOCAL_DESIGNATOR_MIN = 4,
|
||||
RI_LOCAL_DESIGNATOR_MAX = 5,
|
||||
// 6 is reserved
|
||||
RI_LOCAL_STRING_INDEX = 7,
|
||||
RI_LOCAL_STRING_MIN = 8,
|
||||
RI_LOCAL_STRING_MAX = 9,
|
||||
RI_LOCAL_DELIMITER = 10,
|
||||
};
|
||||
|
||||
#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, n)
|
||||
#define HID_USAGE(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, n)
|
||||
|
||||
#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, n)
|
||||
|
||||
#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, 1)
|
||||
#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, n)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Usage Table
|
||||
|
@ -50,39 +50,44 @@
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Multiple Ports)
|
||||
// Application API (Multiple Instances)
|
||||
// CFG_TUD_HID > 1
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Check if the interface is ready to use
|
||||
bool tud_hid_n_ready(uint8_t itf);
|
||||
bool tud_hid_n_ready(uint8_t instance);
|
||||
|
||||
// Check if current mode is Boot (true) or Report (false)
|
||||
bool tud_hid_n_boot_mode(uint8_t itf);
|
||||
// Get interface supported protocol (bInterfaceProtocol) check out hid_interface_protocol_enum_t for possible values
|
||||
uint8_t tud_hid_n_interface_protocol(uint8_t instance);
|
||||
|
||||
// Get current active protocol: HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1)
|
||||
uint8_t tud_hid_n_get_protocol(uint8_t instance);
|
||||
|
||||
// Send report to host
|
||||
bool tud_hid_n_report(uint8_t itf, uint8_t report_id, void const* report, uint8_t len);
|
||||
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len);
|
||||
|
||||
// KEYBOARD: convenient helper to send keyboard report if application
|
||||
// use template layout report as defined by hid_keyboard_report_t
|
||||
bool tud_hid_n_keyboard_report(uint8_t itf, uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
bool tud_hid_n_keyboard_report(uint8_t instance, uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
|
||||
// MOUSE: convenient helper to send mouse report if application
|
||||
// use template layout report as defined by hid_mouse_report_t
|
||||
bool tud_hid_n_mouse_report(uint8_t itf, uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
bool tud_hid_n_mouse_report(uint8_t instance, uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
|
||||
// Gamepad: convenient helper to send mouse report if application
|
||||
// use template layout report TUD_HID_REPORT_DESC_GAMEPAD
|
||||
bool tud_hid_n_gamepad_report(uint8_t itf, uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons);
|
||||
bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Single Port)
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool tud_hid_ready(void);
|
||||
static inline bool tud_hid_boot_mode(void);
|
||||
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
|
||||
static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
static inline bool tud_hid_ready(void);
|
||||
static inline uint8_t tud_hid_interface_protocol(void);
|
||||
static inline uint8_t tud_hid_get_protocol(void);
|
||||
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
|
||||
static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Callbacks (Weak is optional)
|
||||
@ -90,29 +95,30 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
|
||||
// Invoked when received GET HID REPORT DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf);
|
||||
uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance);
|
||||
|
||||
// Invoked when received GET_REPORT control request
|
||||
// Application must fill buffer report's content and return its length.
|
||||
// Return zero will cause the stack to STALL request
|
||||
uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
|
||||
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
|
||||
|
||||
// Invoked when received SET_REPORT control request or
|
||||
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
|
||||
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||
void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||
|
||||
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
|
||||
TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode);
|
||||
// Invoked when received SET_PROTOCOL request
|
||||
// protocol is either HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1)
|
||||
TU_ATTR_WEAK void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol);
|
||||
|
||||
// Invoked when received SET_IDLE request. return false will stall the request
|
||||
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
||||
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
||||
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t itf, uint8_t idle_rate);
|
||||
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t instance, uint8_t idle_rate);
|
||||
|
||||
// Invoked when sent REPORT successfully to host
|
||||
// Application can use this to send the next report
|
||||
// Note: For composite reports, report[0] is report ID
|
||||
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t itf, uint8_t const* report, uint8_t len);
|
||||
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -123,9 +129,14 @@ static inline bool tud_hid_ready(void)
|
||||
return tud_hid_n_ready(0);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_boot_mode(void)
|
||||
static inline uint8_t tud_hid_interface_protocol(void)
|
||||
{
|
||||
return tud_hid_n_boot_mode(0);
|
||||
return tud_hid_n_interface_protocol(0);
|
||||
}
|
||||
|
||||
static inline uint8_t tud_hid_get_protocol(void)
|
||||
{
|
||||
return tud_hid_n_get_protocol(0);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
|
||||
@ -143,6 +154,11 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
return tud_hid_n_mouse_report(0, report_id, buttons, x, y, vertical, horizontal);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons)
|
||||
{
|
||||
return tud_hid_n_gamepad_report(0, report_id, x, y, z, rz, rx, ry, hat, buttons);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------+
|
||||
* HID Report Descriptor Template
|
||||
*
|
||||
@ -184,9 +200,9 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
/* 6-byte Keycodes */ \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\
|
||||
HID_USAGE_MIN ( 0 ) ,\
|
||||
HID_USAGE_MAX ( 255 ) ,\
|
||||
HID_USAGE_MAX_N ( 255, 2 ) ,\
|
||||
HID_LOGICAL_MIN ( 0 ) ,\
|
||||
HID_LOGICAL_MAX ( 255 ) ,\
|
||||
HID_LOGICAL_MAX_N( 255, 2 ) ,\
|
||||
HID_REPORT_COUNT ( 6 ) ,\
|
||||
HID_REPORT_SIZE ( 8 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
|
||||
@ -272,7 +288,7 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
* 0x00 - do nothing
|
||||
* 0x01 - Power Off
|
||||
* 0x02 - Standby
|
||||
* 0x04 - Wake Host
|
||||
* 0x03 - Wake Host
|
||||
*/
|
||||
#define TUD_HID_REPORT_DESC_SYSTEM_CONTROL(...) \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
@ -285,8 +301,8 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
HID_LOGICAL_MAX ( 3 ) ,\
|
||||
HID_REPORT_COUNT ( 1 ) ,\
|
||||
HID_REPORT_SIZE ( 2 ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_SLEEP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_SLEEP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_WAKE_UP ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
|
||||
/* 6 bit padding */ \
|
||||
|
@ -39,166 +39,94 @@
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// KEYBOARD Application API
|
||||
// Class Driver Configuration
|
||||
//--------------------------------------------------------------------+
|
||||
/** \addtogroup ClassDriver_HID_Keyboard Keyboard
|
||||
* @{ */
|
||||
|
||||
/** \defgroup Keyboard_Host Host
|
||||
* The interface API includes status checking function, data transferring function and callback functions
|
||||
* @{ */
|
||||
// TODO Highspeed interrupt can be up to 512 bytes
|
||||
#ifndef CFG_TUH_HID_EP_BUFSIZE
|
||||
#define CFG_TUH_HID_EP_BUFSIZE 64
|
||||
#endif
|
||||
|
||||
extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
|
||||
typedef struct
|
||||
{
|
||||
uint8_t report_id;
|
||||
uint8_t usage;
|
||||
uint16_t usage_page;
|
||||
|
||||
/** \brief Check if device supports Keyboard interface or not
|
||||
* \param[in] dev_addr device address
|
||||
* \retval true if device supports Keyboard interface
|
||||
* \retval false if device does not support Keyboard interface or is not mounted
|
||||
*/
|
||||
bool tuh_hid_keyboard_is_mounted(uint8_t dev_addr);
|
||||
|
||||
/** \brief Check if the interface is currently busy or not
|
||||
* \param[in] dev_addr device address
|
||||
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
|
||||
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
|
||||
* \note This function is primarily used for polling/waiting result after \ref tuh_hid_keyboard_get_report.
|
||||
* Alternatively, asynchronous event API can be used
|
||||
*/
|
||||
bool tuh_hid_keyboard_is_busy(uint8_t dev_addr);
|
||||
|
||||
/** \brief Perform a get report from Keyboard interface
|
||||
* \param[in] dev_addr device address
|
||||
* \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_MEM_SECTION)
|
||||
* \returns \ref tusb_error_t type to indicate success or error condition.
|
||||
* \retval TUSB_ERROR_NONE on success
|
||||
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
|
||||
* \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
|
||||
* \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct
|
||||
* \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
|
||||
*/
|
||||
tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void * p_report);
|
||||
|
||||
//------------- Application Callback -------------//
|
||||
/** \brief Callback function that is invoked when an transferring event occurred
|
||||
* \param[in] dev_addr Address of device
|
||||
* \param[in] event an value from \ref xfer_result_t
|
||||
* \note event can be one of following
|
||||
* - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully.
|
||||
* - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error.
|
||||
* - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device.
|
||||
* \note Application should schedule the next report by calling \ref tuh_hid_keyboard_get_report within this callback
|
||||
*/
|
||||
void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event);
|
||||
|
||||
/** \brief Callback function that will be invoked when a device with Keyboard interface is mounted
|
||||
* \param[in] dev_addr Address of newly mounted device
|
||||
* \note This callback should be used by Application to set-up interface-related data
|
||||
*/
|
||||
void tuh_hid_keyboard_mounted_cb(uint8_t dev_addr);
|
||||
|
||||
/** \brief Callback function that will be invoked when a device with Keyboard interface is unmounted
|
||||
* \param[in] dev_addr Address of newly unmounted device
|
||||
* \note This callback should be used by Application to tear-down interface-related data
|
||||
*/
|
||||
void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr);
|
||||
|
||||
/** @} */ // Keyboard_Host
|
||||
/** @} */ // ClassDriver_HID_Keyboard
|
||||
// TODO still use the endpoint size for now
|
||||
// uint8_t in_len; // length of IN report
|
||||
// uint8_t out_len; // length of OUT report
|
||||
} tuh_hid_report_info_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MOUSE Application API
|
||||
// Application API
|
||||
//--------------------------------------------------------------------+
|
||||
/** \addtogroup ClassDriver_HID_Mouse Mouse
|
||||
* @{ */
|
||||
|
||||
/** \defgroup Mouse_Host Host
|
||||
* The interface API includes status checking function, data transferring function and callback functions
|
||||
* @{ */
|
||||
// Get the number of HID instances
|
||||
uint8_t tuh_hid_instance_count(uint8_t dev_addr);
|
||||
|
||||
/** \brief Check if device supports Mouse interface or not
|
||||
* \param[in] dev_addr device address
|
||||
* \retval true if device supports Mouse interface
|
||||
* \retval false if device does not support Mouse interface or is not mounted
|
||||
*/
|
||||
bool tuh_hid_mouse_is_mounted(uint8_t dev_addr);
|
||||
// Check if HID instance is mounted
|
||||
bool tuh_hid_mounted(uint8_t dev_addr, uint8_t instance);
|
||||
|
||||
/** \brief Check if the interface is currently busy or not
|
||||
* \param[in] dev_addr device address
|
||||
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
|
||||
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
|
||||
* \note This function is primarily used for polling/waiting result after \ref tuh_hid_mouse_get_report.
|
||||
* Alternatively, asynchronous event API can be used
|
||||
*/
|
||||
bool tuh_hid_mouse_is_busy(uint8_t dev_addr);
|
||||
// Get interface supported protocol (bInterfaceProtocol) check out hid_interface_protocol_enum_t for possible values
|
||||
uint8_t tuh_hid_interface_protocol(uint8_t dev_addr, uint8_t instance);
|
||||
|
||||
/** \brief Perform a get report from Mouse interface
|
||||
* \param[in] dev_addr device address
|
||||
* \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_MEM_SECTION)
|
||||
* \returns \ref tusb_error_t type to indicate success or error condition.
|
||||
* \retval TUSB_ERROR_NONE on success
|
||||
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
|
||||
* \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
|
||||
* \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct
|
||||
* \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
|
||||
*/
|
||||
tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void* p_report);
|
||||
// Get current active protocol: HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1)
|
||||
// Note: as HID spec, device will be initialized in Report mode
|
||||
bool tuh_hid_get_protocol(uint8_t dev_addr, uint8_t instance);
|
||||
|
||||
//------------- Application Callback -------------//
|
||||
/** \brief Callback function that is invoked when an transferring event occurred
|
||||
* \param[in] dev_addr Address of device
|
||||
* \param[in] event an value from \ref xfer_result_t
|
||||
* \note event can be one of following
|
||||
* - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully.
|
||||
* - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error.
|
||||
* - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device.
|
||||
* \note Application should schedule the next report by calling \ref tuh_hid_mouse_get_report within this callback
|
||||
*/
|
||||
void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event);
|
||||
// Set protocol to HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1)
|
||||
// This function is only supported by Boot interface (tuh_n_hid_interface_protocol() != NONE)
|
||||
bool tuh_hid_set_protocol(uint8_t dev_addr, uint8_t instance, uint8_t protocol);
|
||||
|
||||
/** \brief Callback function that will be invoked when a device with Mouse interface is mounted
|
||||
* \param[in] dev_addr Address of newly mounted device
|
||||
* \note This callback should be used by Application to set-up interface-related data
|
||||
*/
|
||||
void tuh_hid_mouse_mounted_cb(uint8_t dev_addr);
|
||||
// Set Report using control endpoint
|
||||
// report_type is either Intput, Output or Feature, (value from hid_report_type_t)
|
||||
bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, void* report, uint16_t len);
|
||||
|
||||
/** \brief Callback function that will be invoked when a device with Mouse interface is unmounted
|
||||
* \param[in] dev_addr Address of newly unmounted device
|
||||
* \note This callback should be used by Application to tear-down interface-related data
|
||||
*/
|
||||
void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr);
|
||||
// Parse report descriptor into array of report_info struct and return number of reports.
|
||||
// For complicated report, application should write its own parser.
|
||||
uint8_t tuh_hid_parse_report_descriptor(tuh_hid_report_info_t* reports_info_arr, uint8_t arr_count, uint8_t const* desc_report, uint16_t desc_len) TU_ATTR_UNUSED;
|
||||
|
||||
/** @} */ // Mouse_Host
|
||||
/** @} */ // ClassDriver_HID_Mouse
|
||||
// Check if the interface is ready to use
|
||||
//bool tuh_n_hid_n_ready(uint8_t dev_addr, uint8_t instance);
|
||||
|
||||
// Send report using interrupt endpoint
|
||||
// If report_id > 0 (composite), it will be sent as 1st byte, then report contents. Otherwise only report content is sent.
|
||||
//void tuh_hid_send_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t const* report, uint16_t len);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// GENERIC Application API
|
||||
// Callbacks (Weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
/** \addtogroup ClassDriver_HID_Generic Generic (not supported yet)
|
||||
* @{ */
|
||||
|
||||
/** \defgroup Generic_Host Host
|
||||
* The interface API includes status checking function, data transferring function and callback functions
|
||||
* @{ */
|
||||
// Invoked when device with hid interface is mounted
|
||||
// Report descriptor is also available for use. tuh_hid_parse_report_descriptor()
|
||||
// can be used to parse common/simple enough descriptor.
|
||||
void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report_desc, uint16_t desc_len);
|
||||
|
||||
bool tuh_hid_generic_is_mounted(uint8_t dev_addr);
|
||||
tusb_error_t tuh_hid_generic_get_report(uint8_t dev_addr, void* p_report, bool int_on_complete);
|
||||
tusb_error_t tuh_hid_generic_set_report(uint8_t dev_addr, void* p_report, bool int_on_complete);
|
||||
tusb_interface_status_t tuh_hid_generic_get_status(uint8_t dev_addr);
|
||||
tusb_interface_status_t tuh_hid_generic_set_status(uint8_t dev_addr);
|
||||
// Invoked when device with hid interface is un-mounted
|
||||
TU_ATTR_WEAK void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance);
|
||||
|
||||
//------------- Application Callback -------------//
|
||||
void tuh_hid_generic_isr(uint8_t dev_addr, xfer_result_t event);
|
||||
// Invoked when received report from device via interrupt endpoint
|
||||
// Note: if there is report ID (composite), it is 1st byte of report
|
||||
void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||
|
||||
/** @} */ // Generic_Host
|
||||
/** @} */ // ClassDriver_HID_Generic
|
||||
// Invoked when sent report to device successfully via interrupt endpoint
|
||||
TU_ATTR_WEAK void tuh_hid_report_sent_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||
|
||||
// Invoked when Sent Report to device via either control endpoint
|
||||
// len = 0 indicate there is error in the transfer e.g stalled response
|
||||
TU_ATTR_WEAK void tuh_hid_set_report_complete_cb(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len);
|
||||
|
||||
// Invoked when Set Protocol request is complete
|
||||
TU_ATTR_WEAK void tuh_hid_set_protocol_complete_cb(uint8_t dev_addr, uint8_t instance, uint8_t protocol);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void hidh_init(void);
|
||||
bool hidh_open_subtask(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length);
|
||||
bool hidh_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t *p_length);
|
||||
bool hidh_set_config(uint8_t dev_addr, uint8_t itf_num);
|
||||
bool hidh_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
bool hidh_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void hidh_close(uint8_t dev_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -106,17 +106,17 @@ bool tuh_msc_read_capacity(uint8_t dev_addr, uint8_t lun, scsi_read_capacity10_r
|
||||
//------------- Application Callback -------------//
|
||||
|
||||
// Invoked when a device with MassStorage interface is mounted
|
||||
void tuh_msc_mount_cb(uint8_t dev_addr);
|
||||
TU_ATTR_WEAK void tuh_msc_mount_cb(uint8_t dev_addr);
|
||||
|
||||
// Invoked when a device with MassStorage interface is unmounted
|
||||
void tuh_msc_unmount_cb(uint8_t dev_addr);
|
||||
TU_ATTR_WEAK void tuh_msc_umount_cb(uint8_t dev_addr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void msch_init(void);
|
||||
bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t *p_length);
|
||||
bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t *p_length);
|
||||
bool msch_set_config(uint8_t dev_addr, uint8_t itf_num);
|
||||
bool msch_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void msch_close(uint8_t dev_addr);
|
||||
|
@ -45,7 +45,7 @@ bool tud_vendor_n_mounted (uint8_t itf);
|
||||
|
||||
uint32_t tud_vendor_n_available (uint8_t itf);
|
||||
uint32_t tud_vendor_n_read (uint8_t itf, void* buffer, uint32_t bufsize);
|
||||
bool tud_vendor_n_peek (uint8_t itf, int pos, uint8_t* u8);
|
||||
bool tud_vendor_n_peek (uint8_t itf, uint8_t* u8);
|
||||
|
||||
uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize);
|
||||
uint32_t tud_vendor_n_write_available (uint8_t itf);
|
||||
@ -59,7 +59,7 @@ uint32_t tud_vendor_n_write_str (uint8_t itf, char const* str);
|
||||
static inline bool tud_vendor_mounted (void);
|
||||
static inline uint32_t tud_vendor_available (void);
|
||||
static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize);
|
||||
static inline bool tud_vendor_peek (int pos, uint8_t* u8);
|
||||
static inline bool tud_vendor_peek (uint8_t* u8);
|
||||
static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_vendor_write_str (char const* str);
|
||||
static inline uint32_t tud_vendor_write_available (void);
|
||||
@ -95,9 +95,9 @@ static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize)
|
||||
return tud_vendor_n_read(0, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline bool tud_vendor_peek (int pos, uint8_t* u8)
|
||||
static inline bool tud_vendor_peek (uint8_t* u8)
|
||||
{
|
||||
return tud_vendor_n_peek(0, pos, u8);
|
||||
return tud_vendor_n_peek(0, u8);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
@ -47,13 +47,13 @@
|
||||
#define U16_TO_U8S_BE(u16) TU_U16_HIGH(u16), TU_U16_LOW(u16)
|
||||
#define U16_TO_U8S_LE(u16) TU_U16_LOW(u16), TU_U16_HIGH(u16)
|
||||
|
||||
#define U32_B1_U8(u32) ((uint8_t) ((((uint32_t) u32) >> 24) & 0x000000ff)) // MSB
|
||||
#define U32_B2_U8(u32) ((uint8_t) ((((uint32_t) u32) >> 16) & 0x000000ff))
|
||||
#define U32_B3_U8(u32) ((uint8_t) ((((uint32_t) u32) >> 8) & 0x000000ff))
|
||||
#define U32_B4_U8(u32) ((uint8_t) (((uint32_t) u32) & 0x000000ff)) // LSB
|
||||
#define TU_U32_BYTE3(u32) ((uint8_t) ((((uint32_t) u32) >> 24) & 0x000000ff)) // MSB
|
||||
#define TU_U32_BYTE2(u32) ((uint8_t) ((((uint32_t) u32) >> 16) & 0x000000ff))
|
||||
#define TU_U32_BYTE1(u32) ((uint8_t) ((((uint32_t) u32) >> 8) & 0x000000ff))
|
||||
#define TU_U32_BYTE0(u32) ((uint8_t) (((uint32_t) u32) & 0x000000ff)) // LSB
|
||||
|
||||
#define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
|
||||
#define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
|
||||
#define U32_TO_U8S_BE(u32) TU_U32_BYTE3(u32), TU_U32_BYTE2(u32), TU_U32_BYTE1(u32), TU_U32_BYTE0(u32)
|
||||
#define U32_TO_U8S_LE(u32) TU_U32_BYTE0(u32), TU_U32_BYTE1(u32), TU_U32_BYTE2(u32), TU_U32_BYTE3(u32)
|
||||
|
||||
#define TU_BIT(n) (1U << (n))
|
||||
|
||||
@ -81,9 +81,9 @@
|
||||
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
|
||||
|
||||
//------------- Bytes -------------//
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_u32(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_u32(uint8_t b3, uint8_t b2, uint8_t b1, uint8_t b0)
|
||||
{
|
||||
return ( ((uint32_t) b1) << 24) | ( ((uint32_t) b2) << 16) | ( ((uint32_t) b3) << 8) | b4;
|
||||
return ( ((uint32_t) b3) << 24) | ( ((uint32_t) b2) << 16) | ( ((uint32_t) b1) << 8) | b0;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u16(uint8_t high, uint8_t low)
|
||||
@ -91,8 +91,13 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u16(uint8_t high, uint8_t low)
|
||||
return (uint16_t) ((((uint16_t) high) << 8) | low);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t u16) { return (uint8_t) (((uint16_t) (u16 >> 8)) & 0x00ff); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t u16) { return (uint8_t) (u16 & 0x00ff); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte3(uint32_t u32) { return TU_U32_BYTE3(u32); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte2(uint32_t u32) { return TU_U32_BYTE2(u32); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte1(uint32_t u32) { return TU_U32_BYTE1(u32); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte0(uint32_t u32) { return TU_U32_BYTE0(u32); }
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t u16) { return TU_U16_HIGH(u16); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t u16) { return TU_U16_LOW(u16); }
|
||||
|
||||
//------------- Bits -------------//
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_bit_set (uint32_t value, uint8_t pos) { return value | TU_BIT(pos); }
|
||||
@ -115,8 +120,8 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align(uint32_t value, uint32_t a
|
||||
return value & ((uint32_t) ~(alignment-1));
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align16 (uint32_t value) { return (value & 0xFFFFFFF0UL); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align4k (uint32_t value) { return (value & 0xFFFFF000UL); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_offset4k(uint32_t value) { return (value & 0xFFFUL); }
|
||||
|
||||
@ -141,6 +146,8 @@ static inline uint8_t tu_log2(uint32_t value)
|
||||
//------------- Unaligned Access -------------//
|
||||
#if TUP_ARCH_STRICT_ALIGN
|
||||
|
||||
// Rely on compiler to generate correct code for unaligned access
|
||||
|
||||
typedef struct { uint16_t val; } TU_ATTR_PACKED tu_unaligned_uint16_t;
|
||||
typedef struct { uint32_t val; } TU_ATTR_PACKED tu_unaligned_uint32_t;
|
||||
|
||||
@ -168,8 +175,44 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16(void* mem, uint16_
|
||||
ua16->val = value;
|
||||
}
|
||||
|
||||
#elif TUP_MCU_STRICT_ALIGN
|
||||
|
||||
// MCU such as LPC_IP3511 Highspeed cannot access unaligned memory on USB_RAM although it is ARM M4.
|
||||
// We have to manually pick up bytes since tu_unaligned_uint32_t will still generate unaligned code
|
||||
// NOTE: volatile cast to memory to prevent compiler to optimize and generate unaligned code
|
||||
// TODO Big Endian may need minor changes
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32(const void* mem)
|
||||
{
|
||||
volatile uint8_t const* buf8 = (uint8_t const*) mem;
|
||||
return tu_u32(buf8[3], buf8[2], buf8[1], buf8[0]);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write32(void* mem, uint32_t value)
|
||||
{
|
||||
volatile uint8_t* buf8 = (uint8_t*) mem;
|
||||
buf8[0] = tu_u32_byte0(value);
|
||||
buf8[1] = tu_u32_byte1(value);
|
||||
buf8[2] = tu_u32_byte2(value);
|
||||
buf8[3] = tu_u32_byte3(value);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16(const void* mem)
|
||||
{
|
||||
volatile uint8_t const* buf8 = (uint8_t const*) mem;
|
||||
return tu_u16(buf8[1], buf8[0]);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16(void* mem, uint16_t value)
|
||||
{
|
||||
volatile uint8_t* buf8 = (uint8_t*) mem;
|
||||
buf8[0] = tu_u16_low(value);
|
||||
buf8[1] = tu_u16_high(value);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// MCU that could access unaligned memory natively
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32 (const void* mem ) { return *((uint32_t*) mem); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16 (const void* mem ) { return *((uint16_t*) mem); }
|
||||
|
||||
|
@ -25,10 +25,6 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Common
|
||||
* \defgroup group_fifo fifo
|
||||
* @{ */
|
||||
|
||||
#ifndef _TUSB_FIFO_H_
|
||||
#define _TUSB_FIFO_H_
|
||||
|
||||
@ -62,16 +58,16 @@ extern "C" {
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t* buffer ; ///< buffer pointer
|
||||
uint16_t depth ; ///< max items
|
||||
uint16_t item_size ; ///< size of each item
|
||||
bool overwritable ;
|
||||
uint8_t* buffer ; ///< buffer pointer
|
||||
uint16_t depth ; ///< max items
|
||||
uint16_t item_size ; ///< size of each item
|
||||
bool overwritable ;
|
||||
|
||||
uint16_t non_used_index_space ; ///< required for non-power-of-two buffer length
|
||||
uint16_t max_pointer_idx ; ///< maximum absolute pointer index
|
||||
uint16_t non_used_index_space ; ///< required for non-power-of-two buffer length
|
||||
uint16_t max_pointer_idx ; ///< maximum absolute pointer index
|
||||
|
||||
volatile uint16_t wr_idx ; ///< write pointer
|
||||
volatile uint16_t rd_idx ; ///< read pointer
|
||||
volatile uint16_t wr_idx ; ///< write pointer
|
||||
volatile uint16_t rd_idx ; ///< read pointer
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
tu_fifo_mutex_t mutex_wr;
|
||||
@ -80,6 +76,14 @@ typedef struct
|
||||
|
||||
} tu_fifo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len_lin ; ///< linear length in item size
|
||||
uint16_t len_wrap ; ///< wrapped length in item size
|
||||
void * ptr_lin ; ///< linear part start pointer
|
||||
void * ptr_wrap ; ///< wrapped part start pointer
|
||||
} tu_fifo_buffer_info_t;
|
||||
|
||||
#define TU_FIFO_INIT(_buffer, _depth, _type, _overwritable) \
|
||||
{ \
|
||||
.buffer = _buffer, \
|
||||
@ -115,8 +119,8 @@ bool tu_fifo_read (tu_fifo_t* f, void * p_buffer);
|
||||
uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
|
||||
uint16_t tu_fifo_read_n_const_addr_full_words (tu_fifo_t* f, void * buffer, uint16_t n);
|
||||
|
||||
bool tu_fifo_peek_at (tu_fifo_t* f, uint16_t pos, void * p_buffer);
|
||||
uint16_t tu_fifo_peek_at_n (tu_fifo_t* f, uint16_t pos, void * p_buffer, uint16_t n);
|
||||
bool tu_fifo_peek (tu_fifo_t* f, void * p_buffer);
|
||||
uint16_t tu_fifo_peek_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
|
||||
|
||||
uint16_t tu_fifo_count (tu_fifo_t* f);
|
||||
bool tu_fifo_empty (tu_fifo_t* f);
|
||||
@ -125,27 +129,22 @@ uint16_t tu_fifo_remaining (tu_fifo_t* f);
|
||||
bool tu_fifo_overflowed (tu_fifo_t* f);
|
||||
void tu_fifo_correct_read_pointer (tu_fifo_t* f);
|
||||
|
||||
static inline uint16_t tu_fifo_depth(tu_fifo_t* f)
|
||||
{
|
||||
return f->depth;
|
||||
}
|
||||
|
||||
// Pointer modifications intended to be used in combinations with DMAs.
|
||||
// USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED!
|
||||
void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n);
|
||||
void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
|
||||
|
||||
// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies to handle a possible wrapping part
|
||||
// This functions deliver a pointer to start reading/writing from/to and a valid linear length along which no wrap occurs.
|
||||
// In case not all of your data is available within one read/write, update the read/write pointer by
|
||||
// tu_fifo_advance_read_pointer()/tu_fifo_advance_write_pointer and conduct a second read/write operation
|
||||
uint16_t tu_fifo_get_linear_read_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n);
|
||||
uint16_t tu_fifo_get_linear_write_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n);
|
||||
// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies
|
||||
// to handle a possible wrapping part. These functions deliver a pointer to start
|
||||
// reading/writing from/to and a valid linear length along which no wrap occurs.
|
||||
void tu_fifo_get_read_info (tu_fifo_t *f, tu_fifo_buffer_info_t *info);
|
||||
void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info);
|
||||
|
||||
static inline bool tu_fifo_peek(tu_fifo_t* f, void * p_buffer)
|
||||
{
|
||||
return tu_fifo_peek_at(f, 0, p_buffer);
|
||||
}
|
||||
|
||||
static inline uint16_t tu_fifo_depth(tu_fifo_t* f)
|
||||
{
|
||||
return f->depth;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -309,6 +309,8 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bMaxPower ; ///< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA).
|
||||
} tusb_desc_configuration_t;
|
||||
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_configuration_t) == 9, "size is not correct");
|
||||
|
||||
/// USB Interface Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
@ -421,6 +423,29 @@ typedef struct TU_ATTR_PACKED
|
||||
char url[];
|
||||
} tusb_desc_webusb_url_t;
|
||||
|
||||
// DFU Functional Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
union {
|
||||
struct TU_ATTR_PACKED {
|
||||
uint8_t bitCanDnload : 1;
|
||||
uint8_t bitCanUpload : 1;
|
||||
uint8_t bitManifestationTolerant : 1;
|
||||
uint8_t bitWillDetach : 1;
|
||||
uint8_t reserved : 4;
|
||||
} bmAttributes;
|
||||
|
||||
uint8_t bAttributes;
|
||||
};
|
||||
|
||||
uint16_t wDetachTimeOut;
|
||||
uint16_t wTransferSize;
|
||||
uint16_t bcdDFUVersion;
|
||||
} tusb_desc_dfu_functional_t;
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Types
|
||||
*------------------------------------------------------------------*/
|
||||
|
@ -24,10 +24,6 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/** \ingroup group_usbd
|
||||
* \defgroup group_dcd Device Controller Driver (DCD)
|
||||
* @{ */
|
||||
|
||||
#ifndef _TUSB_DCD_H_
|
||||
#define _TUSB_DCD_H_
|
||||
|
||||
@ -168,5 +164,3 @@ extern void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t x
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_DCD_H_ */
|
||||
|
||||
/// @}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
@ -41,7 +41,10 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Init device stack
|
||||
bool tud_init (void);
|
||||
bool tud_init (uint8_t rhport);
|
||||
|
||||
// Check if device stack is already initialized
|
||||
bool tud_inited(void);
|
||||
|
||||
// Task function should be called in main/rtos loop
|
||||
void tud_task (void);
|
||||
@ -67,6 +70,7 @@ bool tud_mounted(void);
|
||||
bool tud_suspended(void);
|
||||
|
||||
// Check if device is ready to transfer
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline bool tud_ready(void)
|
||||
{
|
||||
return tud_mounted() && !tud_suspended();
|
||||
@ -583,7 +587,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
|
||||
//------------- DFU Runtime -------------//
|
||||
#define TUD_DFU_APP_CLASS (TUSB_CLASS_APPLICATION_SPECIFIC)
|
||||
#define TUD_DFU_APP_SUBCLASS 0x01u
|
||||
#define TUD_DFU_APP_SUBCLASS (APP_SUBCLASS_DFU_RUNTIME)
|
||||
|
||||
// Length of template descriptr: 18 bytes
|
||||
#define TUD_DFU_RT_DESC_LEN (9 + 9)
|
||||
@ -596,6 +600,17 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
/* Function */ \
|
||||
9, DFU_DESC_FUNCTIONAL, _attr, U16_TO_U8S_LE(_timeout), U16_TO_U8S_LE(_xfer_size), U16_TO_U8S_LE(0x0101)
|
||||
|
||||
// Length of template descriptr: 18 bytes
|
||||
#define TUD_DFU_MODE_DESC_LEN (9 + 9)
|
||||
|
||||
// DFU runtime descriptor
|
||||
// Interface number, string index, attributes, detach timeout, transfer size
|
||||
#define TUD_DFU_MODE_DESCRIPTOR(_itfnum, _stridx, _attr, _timeout, _xfer_size) \
|
||||
/* Interface */ \
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUD_DFU_APP_CLASS, TUD_DFU_APP_SUBCLASS, DFU_PROTOCOL_DFU, _stridx, \
|
||||
/* Function */ \
|
||||
9, DFU_DESC_FUNCTIONAL, _attr, U16_TO_U8S_LE(_timeout), U16_TO_U8S_LE(_xfer_size), U16_TO_U8S_LE(0x0101)
|
||||
|
||||
|
||||
//------------- CDC-ECM -------------//
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef struct
|
||||
void (* reset ) (uint8_t rhport);
|
||||
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
|
||||
bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void (* sof ) (uint8_t rhport); /* optional */
|
||||
} usbd_class_driver_t;
|
||||
|
||||
|
@ -24,14 +24,10 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/** \ingroup group_usbh
|
||||
* \defgroup Group_HCD Host Controller Driver (HCD)
|
||||
* @{ */
|
||||
|
||||
#ifndef _TUSB_HCD_H_
|
||||
#define _TUSB_HCD_H_
|
||||
|
||||
#include <common/tusb_common.h>
|
||||
#include "common/tusb_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -85,9 +81,8 @@ typedef struct
|
||||
#if TUSB_OPT_HOST_ENABLED
|
||||
// Max number of endpoints per device
|
||||
enum {
|
||||
HCD_MAX_ENDPOINT = CFG_TUSB_HOST_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID_KEYBOARD + CFG_TUH_HID_MOUSE + CFG_TUSB_HOST_HID_GENERIC +
|
||||
CFG_TUH_MSC*2 + CFG_TUH_CDC*3),
|
||||
|
||||
// TODO better computation
|
||||
HCD_MAX_ENDPOINT = CFG_TUSB_HOST_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3),
|
||||
HCD_MAX_XFER = HCD_MAX_ENDPOINT*2,
|
||||
};
|
||||
|
||||
@ -96,27 +91,46 @@ enum {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Controller & Port API
|
||||
// Controller API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Initialize controller to host mode
|
||||
bool hcd_init(uint8_t rhport);
|
||||
|
||||
// Interrupt Handler
|
||||
void hcd_int_handler(uint8_t rhport);
|
||||
|
||||
// Enable USB interrupt
|
||||
void hcd_int_enable (uint8_t rhport);
|
||||
|
||||
// Disable USB interrupt
|
||||
void hcd_int_disable(uint8_t rhport);
|
||||
|
||||
// Get micro frame number (125 us)
|
||||
uint32_t hcd_uframe_number(uint8_t rhport);
|
||||
|
||||
// Get frame number (1ms)
|
||||
static inline uint32_t hcd_frame_number(uint8_t rhport)
|
||||
TU_ATTR_ALWAYS_INLINE static inline
|
||||
uint32_t hcd_frame_number(uint8_t rhport)
|
||||
{
|
||||
return hcd_uframe_number(rhport) >> 3;
|
||||
}
|
||||
|
||||
/// return the current connect status of roothub port
|
||||
bool hcd_port_connect_status(uint8_t hostid);
|
||||
void hcd_port_reset(uint8_t hostid);
|
||||
//--------------------------------------------------------------------+
|
||||
// Port API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Get the current connect status of roothub port
|
||||
bool hcd_port_connect_status(uint8_t rhport);
|
||||
|
||||
// Reset USB bus on the port
|
||||
void hcd_port_reset(uint8_t rhport);
|
||||
|
||||
// TODO implement later
|
||||
void hcd_port_reset_end(uint8_t rhport);
|
||||
tusb_speed_t hcd_port_speed_get(uint8_t hostid);
|
||||
|
||||
// Get port link speed
|
||||
tusb_speed_t hcd_port_speed_get(uint8_t rhport);
|
||||
|
||||
// HCD closes all opened endpoints belong to this device
|
||||
void hcd_device_close(uint8_t rhport, uint8_t dev_addr);
|
||||
@ -124,6 +138,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr);
|
||||
//--------------------------------------------------------------------+
|
||||
// Endpoints API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]);
|
||||
bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc);
|
||||
|
||||
@ -135,14 +150,12 @@ bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr);
|
||||
bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// PIPE API
|
||||
// PIPE API - TODO remove later
|
||||
//--------------------------------------------------------------------+
|
||||
// TODO control xfer should be used via usbh layer
|
||||
bool hcd_pipe_queue_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], uint16_t total_bytes); // only queue, not transferring yet
|
||||
bool hcd_pipe_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete);
|
||||
|
||||
// tusb_error_t hcd_pipe_cancel();
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Event API (implemented by stack)
|
||||
//--------------------------------------------------------------------+
|
||||
@ -164,5 +177,3 @@ extern void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_HCD_H_ */
|
||||
|
||||
/// @}
|
||||
|
@ -76,7 +76,10 @@ typedef bool (*tuh_control_complete_cb_t)(uint8_t dev_addr, tusb_control_request
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Init host stack
|
||||
bool tuh_init(void);
|
||||
bool tuh_init(uint8_t rhport);
|
||||
|
||||
// Check if host stack is already initialized
|
||||
bool tuh_inited(void);
|
||||
|
||||
// Task function should be called in main/rtos loop
|
||||
void tuh_task(void);
|
||||
@ -85,13 +88,19 @@ void tuh_task(void);
|
||||
extern void hcd_int_handler(uint8_t rhport);
|
||||
#define tuh_int_handler hcd_int_handler
|
||||
|
||||
tusb_device_state_t tuh_device_get_state (uint8_t dev_addr);
|
||||
tusb_speed_t tuh_device_get_speed (uint8_t dev_addr);
|
||||
static inline bool tuh_device_is_configured(uint8_t dev_addr)
|
||||
|
||||
// Check if device is configured
|
||||
bool tuh_device_configured(uint8_t dev_addr);
|
||||
|
||||
// Check if device is ready to communicate with
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline bool tuh_device_ready(uint8_t dev_addr)
|
||||
{
|
||||
return tuh_device_get_state(dev_addr) == TUSB_DEVICE_STATE_CONFIGURED;
|
||||
return tuh_device_configured(dev_addr);
|
||||
}
|
||||
|
||||
// Carry out control transfer
|
||||
bool tuh_control_xfer (uint8_t dev_addr, tusb_control_request_t const* request, void* buffer, tuh_control_complete_cb_t complete_cb);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -121,6 +130,8 @@ void usbh_driver_set_config_complete(uint8_t dev_addr, uint8_t itf_num);
|
||||
|
||||
uint8_t usbh_get_rhport(uint8_t dev_addr);
|
||||
|
||||
uint8_t* usbh_get_enum_buf(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -67,7 +67,7 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
|
||||
BaseType_t xHigherPriorityTaskWoken;
|
||||
BaseType_t res = xSemaphoreGiveFromISR(sem_hdl, &xHigherPriorityTaskWoken);
|
||||
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
|
||||
if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR();
|
||||
#else
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
@ -150,7 +150,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
|
||||
BaseType_t xHigherPriorityTaskWoken;
|
||||
BaseType_t res = xQueueSendToBackFromISR(qhdl, data, &xHigherPriorityTaskWoken);
|
||||
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
|
||||
#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
|
||||
if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR();
|
||||
#else
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
|
@ -57,6 +57,7 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
|
||||
|
||||
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
|
||||
{
|
||||
(void) in_isr;
|
||||
sem_release(sem_hdl);
|
||||
return true;
|
||||
}
|
||||
@ -158,6 +159,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
|
||||
// however osal_queue_recieve may be. therefore my assumption is that
|
||||
// the fifo mutex is not populated for queues used from an IRQ context
|
||||
//assert(!qhdl->ff.mutex);
|
||||
(void) in_isr;
|
||||
|
||||
_osal_q_lock(qhdl);
|
||||
bool success = tu_fifo_write(&qhdl->ff, data);
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, Ha Thach (tinyusb.org)
|
||||
*
|
||||
* Permission is hereby granted, 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_HCD_EHCI_H_
|
||||
#define _TUSB_HCD_EHCI_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// API Implemented by HCD
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Get operational address i.e EHCI Command register
|
||||
uint32_t hcd_ehci_register_addr(uint8_t rhport);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// API Implemented by EHCI
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Initialize EHCI driver
|
||||
extern bool hcd_ehci_init (uint8_t rhport);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
@ -42,7 +42,7 @@
|
||||
#if TUSB_OPT_HOST_ENABLED
|
||||
#include "host/usbh.h"
|
||||
|
||||
#if HOST_CLASS_HID
|
||||
#if CFG_TUH_HID
|
||||
#include "class/hid/hid_host.h"
|
||||
#endif
|
||||
|
||||
@ -96,6 +96,10 @@
|
||||
#include "class/dfu/dfu_rt_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_DFU_MODE
|
||||
#include "class/dfu/dfu_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_NET
|
||||
#include "class/net/net_device.h"
|
||||
#endif
|
||||
|
@ -94,6 +94,7 @@
|
||||
|
||||
// Espressif
|
||||
#define OPT_MCU_ESP32S2 900 ///< Espressif ESP32-S2
|
||||
#define OPT_MCU_ESP32S3 901 ///< Espressif ESP32-S3
|
||||
|
||||
// Dialog
|
||||
#define OPT_MCU_DA1469X 1000 ///< Dialog Semiconductor DA1469x
|
||||
@ -240,7 +241,15 @@
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_DFU_RUNTIME
|
||||
#define CFG_TUD_DFU_RUNTIME 0
|
||||
#define CFG_TUD_DFU_RUNTIME 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_DFU_MODE
|
||||
#define CFG_TUD_DFU_MODE 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_DFU_TRANSFER_BUFFER_SIZE
|
||||
#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 64
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_NET
|
||||
@ -265,11 +274,8 @@
|
||||
#error there is no benefit enable hub with max device is 1. Please disable hub or increase CFG_TUSB_HOST_DEVICE_MAX
|
||||
#endif
|
||||
|
||||
//------------- HID CLASS -------------//
|
||||
#define HOST_CLASS_HID ( CFG_TUH_HID_KEYBOARD + CFG_TUH_HID_MOUSE + CFG_TUSB_HOST_HID_GENERIC )
|
||||
|
||||
#ifndef CFG_TUSB_HOST_ENUM_BUFFER_SIZE
|
||||
#define CFG_TUSB_HOST_ENUM_BUFFER_SIZE 256
|
||||
#ifndef CFG_TUH_ENUMERATION_BUFSZIE
|
||||
#define CFG_TUH_ENUMERATION_BUFSZIE 256
|
||||
#endif
|
||||
|
||||
//------------- CLASS -------------//
|
||||
@ -282,6 +288,7 @@
|
||||
|
||||
// TUP_ARCH_STRICT_ALIGN if arch cannot access unaligned memory
|
||||
|
||||
|
||||
// ARMv7+ (M3-M7, M23-M33) can access unaligned memory
|
||||
#if (defined(__ARM_ARCH) && (__ARM_ARCH >= 7))
|
||||
#define TUP_ARCH_STRICT_ALIGN 0
|
||||
@ -289,6 +296,16 @@
|
||||
#define TUP_ARCH_STRICT_ALIGN 1
|
||||
#endif
|
||||
|
||||
// TUP_MCU_STRICT_ALIGN will overwrite TUP_ARCH_STRICT_ALIGN.
|
||||
// In case TUP_MCU_STRICT_ALIGN = 1 and TUP_ARCH_STRICT_ALIGN =0, we will not reply on compiler
|
||||
// to generate unaligned access code.
|
||||
// LPC_IP3511 Highspeed cannot access unaligned memory on USB_RAM
|
||||
#if TUD_OPT_HIGH_SPEED && (CFG_TUSB_MCU == OPT_MCU_LPC54XXX || CFG_TUSB_MCU == OPT_MCU_LPC55XX)
|
||||
#define TUP_MCU_STRICT_ALIGN 1
|
||||
#else
|
||||
#define TUP_MCU_STRICT_ALIGN 0
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Configuration Validation
|
||||
//------------------------------------------------------------------
|
||||
|
@ -24,13 +24,14 @@ extern "C" {
|
||||
* @brief Enable early entropy source for RNG
|
||||
*
|
||||
* Uses the SAR ADC to feed entropy into the HWRNG. The ADC is put
|
||||
* into a test mode that reads the 1.1V internal reference source and
|
||||
* feeds the LSB of data into the HWRNG.
|
||||
* into a test mode that reads an internal reference voltage and
|
||||
* constantly feeds the LSB of data into the HWRNG. Consult the
|
||||
* SoC Technical Reference Manual for more information.
|
||||
*
|
||||
* Can also be used from app code early during operation, if entropy
|
||||
* is required before WiFi stack is initialised. Call this function
|
||||
* from app code only if WiFi/BT are not yet enabled and I2S and SAR
|
||||
* ADC are not in use.
|
||||
* Can also be used from app code early during operation, if true
|
||||
* random numbers are required before WiFi stack is initialised.
|
||||
* Call this function from app code only if WiFi/BT are not yet
|
||||
* enabled and I2S and ADC are not in use.
|
||||
*
|
||||
* Call bootloader_random_disable() when done.
|
||||
*/
|
||||
|
@ -70,11 +70,9 @@
|
||||
#define CONFIG_TINYUSB_MSC_ENABLED 1
|
||||
#define CONFIG_TINYUSB_DESC_MSC_STRING "Espressif MSC Device"
|
||||
#define CONFIG_TINYUSB_MSC_BUFSIZE 512
|
||||
#define CONFIG_USB_HID_ENABLED 1
|
||||
#define CONFIG_TINYUSB_MIDI_ENABLED 1
|
||||
#define CONFIG_TINYUSB_DESC_MIDI_STRING "Espressif MIDI Device"
|
||||
#define CONFIG_TINYUSB_MIDI_RX_BUFSIZE 64
|
||||
#define CONFIG_TINYUSB_MIDI_TX_BUFSIZE 64
|
||||
#define CONFIG_TINYUSB_HID_ENABLED 1
|
||||
#define CONFIG_TINYUSB_DESC_HID_STRING "Espressif HID Device"
|
||||
#define CONFIG_TINYUSB_HID_BUFSIZE 64
|
||||
#define CONFIG_TINYUSB_DFU_RT_ENABLED 1
|
||||
#define CONFIG_TINYUSB_DESC_DFU_RT_STRING "Espressif DFU Device"
|
||||
#define CONFIG_TINYUSB_VENDOR_ENABLED 1
|
||||
@ -218,8 +216,6 @@
|
||||
#define CONFIG_ESP32_WIFI_NVS_ENABLED 1
|
||||
#define CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN 752
|
||||
#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32
|
||||
#define CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT 1
|
||||
#define CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_ESP_COREDUMP_ENABLE_TO_NONE 1
|
||||
@ -278,6 +274,8 @@
|
||||
#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 1
|
||||
#define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1
|
||||
#define CONFIG_LOG_MAXIMUM_LEVEL 1
|
||||
#define CONFIG_LOG_TIMESTAMP_SOURCE_RTOS 1
|
||||
#define CONFIG_LWIP_LOCAL_HOSTNAME "espressif"
|
||||
#define CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES 1
|
||||
@ -296,6 +294,7 @@
|
||||
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
|
||||
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
|
||||
#define CONFIG_LWIP_IPV6 1
|
||||
#define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3
|
||||
#define CONFIG_LWIP_NETIF_LOOPBACK 1
|
||||
#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8
|
||||
#define CONFIG_LWIP_MAX_ACTIVE_TCP 16
|
||||
@ -332,6 +331,7 @@
|
||||
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
|
||||
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
|
||||
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
|
||||
#define CONFIG_LWIP_HOOK_ND6_GET_GW_NONE 1
|
||||
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
|
||||
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
@ -340,6 +340,7 @@
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1
|
||||
#define CONFIG_MBEDTLS_HARDWARE_GCM 1
|
||||
#define CONFIG_MBEDTLS_ROM_MD5 1
|
||||
#define CONFIG_MBEDTLS_HAVE_TIME 1
|
||||
#define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1
|
||||
#define CONFIG_MBEDTLS_SHA512_C 1
|
||||
@ -459,6 +460,13 @@
|
||||
#define CONFIG_MFN56_1X 1
|
||||
#define CONFIG_HD_NANO1 1
|
||||
#define CONFIG_HP_NANO1 1
|
||||
#define CONFIG_OV7670_SUPPORT 1
|
||||
#define CONFIG_NT99141_SUPPORT 1
|
||||
#define CONFIG_OV2640_SUPPORT 1
|
||||
#define CONFIG_OV3660_SUPPORT 1
|
||||
#define CONFIG_OV5640_SUPPORT 1
|
||||
#define CONFIG_SCCB_HARDWARE_I2C_PORT1 1
|
||||
#define CONFIG_CAMERA_CORE0 1
|
||||
#define CONFIG_LITTLEFS_MAX_PARTITIONS 3
|
||||
#define CONFIG_LITTLEFS_PAGE_SIZE 256
|
||||
#define CONFIG_LITTLEFS_OBJ_NAME_LEN 64
|
||||
@ -549,5 +557,5 @@
|
||||
#define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX
|
||||
#define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE
|
||||
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "cf457d412"
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "c13afea63"
|
||||
#define CONFIG_ARDUINO_IDF_BRANCH "master"
|
||||
|
@ -49,8 +49,8 @@ typedef enum {
|
||||
ADC1_CHANNEL_5, /*!< ADC1 channel 5 is GPIO6 */
|
||||
ADC1_CHANNEL_6, /*!< ADC1 channel 6 is GPIO7 */
|
||||
ADC1_CHANNEL_7, /*!< ADC1 channel 7 is GPIO8 */
|
||||
ADC1_CHANNEL_8, /*!< ADC1 channel 6 is GPIO9 */
|
||||
ADC1_CHANNEL_9, /*!< ADC1 channel 7 is GPIO10 */
|
||||
ADC1_CHANNEL_8, /*!< ADC1 channel 8 is GPIO9 */
|
||||
ADC1_CHANNEL_9, /*!< ADC1 channel 9 is GPIO10 */
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
@ -135,7 +135,7 @@ typedef enum {
|
||||
* @brief Digital ADC DMA configuration
|
||||
*/
|
||||
typedef struct adc_digi_init_config_s {
|
||||
uint32_t max_store_buf_size; ///< Max length of the converted data that driver can store before they are processed. When this length is reached, driver will dump out all the old data and start to store them again.
|
||||
uint32_t max_store_buf_size; ///< Max length of the converted data that driver can store before they are processed.
|
||||
uint32_t conv_num_each_intr; ///< Bytes of data that can be converted in 1 interrupt.
|
||||
uint32_t adc1_chan_mask; ///< Channel list of ADC1 to be initialized.
|
||||
uint32_t adc2_chan_mask; ///< Channel list of ADC2 to be initialized.
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "esp32s3/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
|
||||
@ -215,9 +217,9 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
* per-GPIO ISRs.
|
||||
*
|
||||
* @param fn Interrupt handler function.
|
||||
* @param arg Parameter for handler function
|
||||
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
|
||||
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
|
||||
* @param arg Parameter for handler function
|
||||
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
|
||||
*
|
||||
* \verbatim embed:rst:leading-asterisk
|
||||
|
@ -76,6 +76,7 @@ esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Set LEDC output gpio.
|
||||
* @deprecated This function is redundant, please use ledc_channel_config to set gpio pins.
|
||||
*
|
||||
* @param gpio_num The LEDC output gpio
|
||||
* @param speed_mode Select the LEDC channel group with specified speed mode. Note that not all targets support high speed mode.
|
||||
@ -85,8 +86,8 @@ esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_set_pin(int gpio_num, ledc_mode_t speed_mode, ledc_channel_t ledc_channel);
|
||||
|
||||
esp_err_t ledc_set_pin(int gpio_num, ledc_mode_t speed_mode, ledc_channel_t ledc_channel)
|
||||
__attribute__((deprecated("use ledc_channel_config instead")));
|
||||
/**
|
||||
* @brief LEDC stop.
|
||||
* Disable LEDC output, and set idle level
|
||||
|
@ -568,6 +568,7 @@ esp_err_t mcpwm_fault_deinit(mcpwm_unit_t mcpwm_num, mcpwm_fault_signal_t fault_
|
||||
* @param cap_edge set capture edge, BIT(0) - negative edge, BIT(1) - positive edge
|
||||
* @param cap_sig capture pin, which needs to be enabled
|
||||
* @param num_of_pulse count time between rising/falling edge between 2 *(pulses mentioned), counter uses APB_CLK
|
||||
* [0~MCPWM_LL_MAX_PRESCALE] (MCPWM_LL_MAX_PRESCALE = 255 on ESP32);
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
|
@ -58,7 +58,9 @@ typedef enum {
|
||||
typedef struct {
|
||||
slave_cb_t cb_buffer_tx; ///< Callback when master reads from shared buffer
|
||||
slave_cb_t cb_buffer_rx; ///< Callback when master writes to shared buffer
|
||||
slave_cb_t cb_send_dma_ready; ///< Callback when TX data buffer is loaded to the hardware (DMA)
|
||||
slave_cb_t cb_sent; ///< Callback when data are sent
|
||||
slave_cb_t cb_recv_dma_ready; ///< Callback when RX data buffer is loaded to the hardware (DMA)
|
||||
slave_cb_t cb_recv; ///< Callback when data are received
|
||||
slave_cb_t cb_cmd9; ///< Callback when CMD9 received
|
||||
slave_cb_t cb_cmdA; ///< Callback when CMDA received
|
||||
|
@ -432,6 +432,8 @@ void timer_group_clr_intr_sta_in_isr(timer_group_t group_num, timer_intr_t intr_
|
||||
bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num);
|
||||
|
||||
/** @brief Take timer spinlock to enter critical protect
|
||||
*
|
||||
* @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main
|
||||
*
|
||||
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
|
||||
*
|
||||
@ -439,9 +441,11 @@ bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t tim
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t timer_spinlock_take(timer_group_t group_num);
|
||||
esp_err_t timer_spinlock_take(timer_group_t group_num) __attribute__ ((deprecated));
|
||||
|
||||
/** @brief Give timer spinlock to exit critical protect
|
||||
*
|
||||
* @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main
|
||||
*
|
||||
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
|
||||
*
|
||||
@ -449,7 +453,7 @@ esp_err_t timer_spinlock_take(timer_group_t group_num);
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t timer_spinlock_give(timer_group_t group_num);
|
||||
esp_err_t timer_spinlock_give(timer_group_t group_num) __attribute__ ((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ esp_err_t gdma_new_channel(const gdma_channel_alloc_config_t *config, gdma_chann
|
||||
* @brief Connect GDMA channel to trigger peripheral
|
||||
*
|
||||
* @note Suggest to use helper macro `GDMA_MAKE_TRIGGER` to construct parameter `trig_periph`. e.g. GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_SHA,0)
|
||||
* @note Connecting to a peripheral will also reset the DMA FIFO and FSM automatically
|
||||
*
|
||||
* @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
||||
* @param[in] trig_periph GDMA trigger peripheral
|
||||
@ -279,6 +280,18 @@ esp_err_t gdma_stop(gdma_channel_handle_t dma_chan);
|
||||
*/
|
||||
esp_err_t gdma_append(gdma_channel_handle_t dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Reset DMA channel FIFO and internal finite state machine
|
||||
* @note Resetting a DMA channel won't break the connection with the target peripheral
|
||||
*
|
||||
* @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
||||
* @return
|
||||
* - ESP_OK: DMA channel reset successfully
|
||||
* - ESP_ERR_INVALID_ARG: DMA channel reset failed due to invalid arguments
|
||||
* - ESP_FAIL: DMA channel reset failed due to other errors
|
||||
*/
|
||||
esp_err_t gdma_reset(gdma_channel_handle_t dma_chan);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,43 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _ESP_JPG_DECODE_H_
|
||||
#define _ESP_JPG_DECODE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
typedef enum {
|
||||
JPG_SCALE_NONE,
|
||||
JPG_SCALE_2X,
|
||||
JPG_SCALE_4X,
|
||||
JPG_SCALE_8X,
|
||||
JPG_SCALE_MAX = JPG_SCALE_8X
|
||||
} jpg_scale_t;
|
||||
|
||||
typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len);
|
||||
typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data);
|
||||
|
||||
esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_JPG_DECODE_H_ */
|
@ -0,0 +1,130 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _IMG_CONVERTERS_H_
|
||||
#define _IMG_CONVERTERS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_camera.h"
|
||||
#include "esp_jpg_decode.h"
|
||||
|
||||
typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Convert image buffer to JPEG
|
||||
*
|
||||
* @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format
|
||||
* @param src_len Length in bytes of the source buffer
|
||||
* @param width Width in pixels of the source image
|
||||
* @param height Height in pixels of the source image
|
||||
* @param format Format of the source image
|
||||
* @param quality JPEG quality of the resulting image
|
||||
* @param cp Callback to be called to write the bytes of the output JPEG
|
||||
* @param arg Pointer to be passed to the callback
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg);
|
||||
|
||||
/**
|
||||
* @brief Convert camera frame buffer to JPEG
|
||||
*
|
||||
* @param fb Source camera frame buffer
|
||||
* @param quality JPEG quality of the resulting image
|
||||
* @param cp Callback to be called to write the bytes of the output JPEG
|
||||
* @param arg Pointer to be passed to the callback
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg);
|
||||
|
||||
/**
|
||||
* @brief Convert image buffer to JPEG buffer
|
||||
*
|
||||
* @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format
|
||||
* @param src_len Length in bytes of the source buffer
|
||||
* @param width Width in pixels of the source image
|
||||
* @param height Height in pixels of the source image
|
||||
* @param format Format of the source image
|
||||
* @param quality JPEG quality of the resulting image
|
||||
* @param out Pointer to be populated with the address of the resulting buffer.
|
||||
* You MUST free the pointer once you are done with it.
|
||||
* @param out_len Pointer to be populated with the length of the output buffer
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len);
|
||||
|
||||
/**
|
||||
* @brief Convert camera frame buffer to JPEG buffer
|
||||
*
|
||||
* @param fb Source camera frame buffer
|
||||
* @param quality JPEG quality of the resulting image
|
||||
* @param out Pointer to be populated with the address of the resulting buffer
|
||||
* @param out_len Pointer to be populated with the length of the output buffer
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len);
|
||||
|
||||
/**
|
||||
* @brief Convert image buffer to BMP buffer
|
||||
*
|
||||
* @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format
|
||||
* @param src_len Length in bytes of the source buffer
|
||||
* @param width Width in pixels of the source image
|
||||
* @param height Height in pixels of the source image
|
||||
* @param format Format of the source image
|
||||
* @param out Pointer to be populated with the address of the resulting buffer
|
||||
* @param out_len Pointer to be populated with the length of the output buffer
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t ** out, size_t * out_len);
|
||||
|
||||
/**
|
||||
* @brief Convert camera frame buffer to BMP buffer
|
||||
*
|
||||
* @param fb Source camera frame buffer
|
||||
* @param out Pointer to be populated with the address of the resulting buffer
|
||||
* @param out_len Pointer to be populated with the length of the output buffer
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len);
|
||||
|
||||
/**
|
||||
* @brief Convert image buffer to RGB888 buffer (used for face detection)
|
||||
*
|
||||
* @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format
|
||||
* @param src_len Length in bytes of the source buffer
|
||||
* @param format Format of the source image
|
||||
* @param rgb_buf Pointer to the output buffer (width * height * 3)
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf);
|
||||
|
||||
bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IMG_CONVERTERS_H_ */
|
205
tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h
Executable file
205
tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h
Executable file
@ -0,0 +1,205 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* Example Use
|
||||
*
|
||||
static camera_config_t camera_example_config = {
|
||||
.pin_pwdn = PIN_PWDN,
|
||||
.pin_reset = PIN_RESET,
|
||||
.pin_xclk = PIN_XCLK,
|
||||
.pin_sscb_sda = PIN_SIOD,
|
||||
.pin_sscb_scl = PIN_SIOC,
|
||||
.pin_d7 = PIN_D7,
|
||||
.pin_d6 = PIN_D6,
|
||||
.pin_d5 = PIN_D5,
|
||||
.pin_d4 = PIN_D4,
|
||||
.pin_d3 = PIN_D3,
|
||||
.pin_d2 = PIN_D2,
|
||||
.pin_d1 = PIN_D1,
|
||||
.pin_d0 = PIN_D0,
|
||||
.pin_vsync = PIN_VSYNC,
|
||||
.pin_href = PIN_HREF,
|
||||
.pin_pclk = PIN_PCLK,
|
||||
|
||||
.xclk_freq_hz = 20000000,
|
||||
.ledc_timer = LEDC_TIMER_0,
|
||||
.ledc_channel = LEDC_CHANNEL_0,
|
||||
.pixel_format = PIXFORMAT_JPEG,
|
||||
.frame_size = FRAMESIZE_SVGA,
|
||||
.jpeg_quality = 10,
|
||||
.fb_count = 2,
|
||||
.grab_mode = CAMERA_GRAB_WHEN_EMPTY
|
||||
};
|
||||
|
||||
esp_err_t camera_example_init(){
|
||||
return esp_camera_init(&camera_example_config);
|
||||
}
|
||||
|
||||
esp_err_t camera_example_capture(){
|
||||
//capture a frame
|
||||
camera_fb_t * fb = esp_camera_fb_get();
|
||||
if (!fb) {
|
||||
ESP_LOGE(TAG, "Frame buffer could not be acquired");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
//replace this with your own function
|
||||
display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len);
|
||||
|
||||
//return the frame buffer back to be reused
|
||||
esp_camera_fb_return(fb);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "sensor.h"
|
||||
#include "sys/time.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration structure for camera initialization
|
||||
*/
|
||||
typedef enum {
|
||||
CAMERA_GRAB_WHEN_EMPTY, /*!< Fills buffers when they are empty. Less resources but first 'fb_count' frames might be old */
|
||||
CAMERA_GRAB_LATEST /*!< Except when 1 frame buffer is used, queue will always contain the last 'fb_count' frames */
|
||||
} camera_grab_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration structure for camera initialization
|
||||
*/
|
||||
typedef struct {
|
||||
int pin_pwdn; /*!< GPIO pin for camera power down line */
|
||||
int pin_reset; /*!< GPIO pin for camera reset line */
|
||||
int pin_xclk; /*!< GPIO pin for camera XCLK line */
|
||||
int pin_sscb_sda; /*!< GPIO pin for camera SDA line */
|
||||
int pin_sscb_scl; /*!< GPIO pin for camera SCL line */
|
||||
int pin_d7; /*!< GPIO pin for camera D7 line */
|
||||
int pin_d6; /*!< GPIO pin for camera D6 line */
|
||||
int pin_d5; /*!< GPIO pin for camera D5 line */
|
||||
int pin_d4; /*!< GPIO pin for camera D4 line */
|
||||
int pin_d3; /*!< GPIO pin for camera D3 line */
|
||||
int pin_d2; /*!< GPIO pin for camera D2 line */
|
||||
int pin_d1; /*!< GPIO pin for camera D1 line */
|
||||
int pin_d0; /*!< GPIO pin for camera D0 line */
|
||||
int pin_vsync; /*!< GPIO pin for camera VSYNC line */
|
||||
int pin_href; /*!< GPIO pin for camera HREF line */
|
||||
int pin_pclk; /*!< GPIO pin for camera PCLK line */
|
||||
|
||||
int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. Either 20KHz or 10KHz for OV2640 double FPS (Experimental) */
|
||||
|
||||
ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */
|
||||
ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */
|
||||
|
||||
pixformat_t pixel_format; /*!< Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG */
|
||||
framesize_t frame_size; /*!< Size of the output image: FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA */
|
||||
|
||||
int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */
|
||||
size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */
|
||||
camera_grab_mode_t grab_mode; /*!< When buffers should be filled */
|
||||
} camera_config_t;
|
||||
|
||||
/**
|
||||
* @brief Data structure of camera frame buffer
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t * buf; /*!< Pointer to the pixel data */
|
||||
size_t len; /*!< Length of the buffer in bytes */
|
||||
size_t width; /*!< Width of the buffer in pixels */
|
||||
size_t height; /*!< Height of the buffer in pixels */
|
||||
pixformat_t format; /*!< Format of the pixel data */
|
||||
struct timeval timestamp; /*!< Timestamp since boot of the first DMA buffer of the frame */
|
||||
} camera_fb_t;
|
||||
|
||||
#define ESP_ERR_CAMERA_BASE 0x20000
|
||||
#define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1)
|
||||
#define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2)
|
||||
#define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 3)
|
||||
#define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 4)
|
||||
|
||||
/**
|
||||
* @brief Initialize the camera driver
|
||||
*
|
||||
* @note call camera_probe before calling this function
|
||||
*
|
||||
* This function detects and configures camera over I2C interface,
|
||||
* allocates framebuffer and DMA buffers,
|
||||
* initializes parallel I2S input, and sets up DMA descriptors.
|
||||
*
|
||||
* Currently this function can only be called once and there is
|
||||
* no way to de-initialize this module.
|
||||
*
|
||||
* @param config Camera configuration parameters
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_camera_init(const camera_config_t* config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the camera driver
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet
|
||||
*/
|
||||
esp_err_t esp_camera_deinit();
|
||||
|
||||
/**
|
||||
* @brief Obtain pointer to a frame buffer.
|
||||
*
|
||||
* @return pointer to the frame buffer
|
||||
*/
|
||||
camera_fb_t* esp_camera_fb_get();
|
||||
|
||||
/**
|
||||
* @brief Return the frame buffer to be reused again.
|
||||
*
|
||||
* @param fb Pointer to the frame buffer
|
||||
*/
|
||||
void esp_camera_fb_return(camera_fb_t * fb);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the image sensor control structure
|
||||
*
|
||||
* @return pointer to the sensor
|
||||
*/
|
||||
sensor_t * esp_camera_sensor_get();
|
||||
|
||||
/**
|
||||
* @brief Save camera settings to non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_save_to_nvs(const char *key);
|
||||
|
||||
/**
|
||||
* @brief Load camera settings from non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_load_from_nvs(const char *key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "img_converters.h"
|
||||
|
234
tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h
Executable file
234
tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h
Executable file
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* This file is part of the OpenMV project.
|
||||
* Copyright (c) 2013/2014 Ibrahim Abdelkader <i.abdalkader@gmail.com>
|
||||
* This work is licensed under the MIT license, see the file LICENSE for details.
|
||||
*
|
||||
* Sensor abstraction layer.
|
||||
*
|
||||
*/
|
||||
#ifndef __SENSOR_H__
|
||||
#define __SENSOR_H__
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// Chip ID Registers
|
||||
#define REG_PID 0x0A
|
||||
#define REG_VER 0x0B
|
||||
#define REG_MIDH 0x1C
|
||||
#define REG_MIDL 0x1D
|
||||
|
||||
#define REG16_CHIDH 0x300A
|
||||
#define REG16_CHIDL 0x300B
|
||||
|
||||
typedef enum {
|
||||
OV9650_PID = 0x96,
|
||||
OV7725_PID = 0x77,
|
||||
OV2640_PID = 0x26,
|
||||
OV3660_PID = 0x36,
|
||||
OV5640_PID = 0x56,
|
||||
OV7670_PID = 0x76,
|
||||
NT99141_PID = 0x14
|
||||
} camera_pid_t;
|
||||
|
||||
typedef enum {
|
||||
CAMERA_OV7725,
|
||||
CAMERA_OV2640,
|
||||
CAMERA_OV3660,
|
||||
CAMERA_OV5640,
|
||||
CAMERA_OV7670,
|
||||
CAMERA_NT99141,
|
||||
CAMERA_MODEL_MAX,
|
||||
CAMERA_NONE,
|
||||
CAMERA_UNKNOWN
|
||||
} camera_model_t;
|
||||
|
||||
typedef enum {
|
||||
OV2640_SCCB_ADDR = 0x30,
|
||||
OV5640_SCCB_ADDR = 0x3C,
|
||||
OV3660_SCCB_ADDR = 0x3C,
|
||||
OV7725_SCCB_ADDR = 0x21,
|
||||
OV7670_SCCB_ADDR = 0x21,
|
||||
NT99141_SCCB_ADDR = 0x2A,
|
||||
} camera_sccb_addr_t;
|
||||
|
||||
typedef enum {
|
||||
PIXFORMAT_RGB565, // 2BPP/RGB565
|
||||
PIXFORMAT_YUV422, // 2BPP/YUV422
|
||||
PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE
|
||||
PIXFORMAT_JPEG, // JPEG/COMPRESSED
|
||||
PIXFORMAT_RGB888, // 3BPP/RGB888
|
||||
PIXFORMAT_RAW, // RAW
|
||||
PIXFORMAT_RGB444, // 3BP2P/RGB444
|
||||
PIXFORMAT_RGB555, // 3BP2P/RGB555
|
||||
} pixformat_t;
|
||||
|
||||
typedef enum {
|
||||
FRAMESIZE_96X96, // 96x96
|
||||
FRAMESIZE_QQVGA, // 160x120
|
||||
FRAMESIZE_QCIF, // 176x144
|
||||
FRAMESIZE_HQVGA, // 240x176
|
||||
FRAMESIZE_240X240, // 240x240
|
||||
FRAMESIZE_QVGA, // 320x240
|
||||
FRAMESIZE_CIF, // 400x296
|
||||
FRAMESIZE_HVGA, // 480x320
|
||||
FRAMESIZE_VGA, // 640x480
|
||||
FRAMESIZE_SVGA, // 800x600
|
||||
FRAMESIZE_XGA, // 1024x768
|
||||
FRAMESIZE_HD, // 1280x720
|
||||
FRAMESIZE_SXGA, // 1280x1024
|
||||
FRAMESIZE_UXGA, // 1600x1200
|
||||
// 3MP Sensors
|
||||
FRAMESIZE_FHD, // 1920x1080
|
||||
FRAMESIZE_P_HD, // 720x1280
|
||||
FRAMESIZE_P_3MP, // 864x1536
|
||||
FRAMESIZE_QXGA, // 2048x1536
|
||||
// 5MP Sensors
|
||||
FRAMESIZE_QHD, // 2560x1440
|
||||
FRAMESIZE_WQXGA, // 2560x1600
|
||||
FRAMESIZE_P_FHD, // 1080x1920
|
||||
FRAMESIZE_QSXGA, // 2560x1920
|
||||
FRAMESIZE_INVALID
|
||||
} framesize_t;
|
||||
|
||||
typedef struct {
|
||||
const camera_model_t model;
|
||||
const camera_sccb_addr_t sccb_addr;
|
||||
const camera_pid_t pid;
|
||||
const framesize_t max_size;
|
||||
} camera_sensor_info_t;
|
||||
|
||||
typedef enum {
|
||||
ASPECT_RATIO_4X3,
|
||||
ASPECT_RATIO_3X2,
|
||||
ASPECT_RATIO_16X10,
|
||||
ASPECT_RATIO_5X3,
|
||||
ASPECT_RATIO_16X9,
|
||||
ASPECT_RATIO_21X9,
|
||||
ASPECT_RATIO_5X4,
|
||||
ASPECT_RATIO_1X1,
|
||||
ASPECT_RATIO_9X16
|
||||
} aspect_ratio_t;
|
||||
|
||||
typedef enum {
|
||||
GAINCEILING_2X,
|
||||
GAINCEILING_4X,
|
||||
GAINCEILING_8X,
|
||||
GAINCEILING_16X,
|
||||
GAINCEILING_32X,
|
||||
GAINCEILING_64X,
|
||||
GAINCEILING_128X,
|
||||
} gainceiling_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t max_width;
|
||||
uint16_t max_height;
|
||||
uint16_t start_x;
|
||||
uint16_t start_y;
|
||||
uint16_t end_x;
|
||||
uint16_t end_y;
|
||||
uint16_t offset_x;
|
||||
uint16_t offset_y;
|
||||
uint16_t total_x;
|
||||
uint16_t total_y;
|
||||
} ratio_settings_t;
|
||||
|
||||
typedef struct {
|
||||
const uint16_t width;
|
||||
const uint16_t height;
|
||||
const aspect_ratio_t aspect_ratio;
|
||||
} resolution_info_t;
|
||||
|
||||
// Resolution table (in sensor.c)
|
||||
extern const resolution_info_t resolution[];
|
||||
// camera sensor table (in sensor.c)
|
||||
extern const camera_sensor_info_t camera_sensor[];
|
||||
|
||||
typedef struct {
|
||||
uint8_t MIDH;
|
||||
uint8_t MIDL;
|
||||
uint8_t PID;
|
||||
uint8_t VER;
|
||||
} sensor_id_t;
|
||||
|
||||
typedef struct {
|
||||
framesize_t framesize;//0 - 10
|
||||
bool scale;
|
||||
bool binning;
|
||||
uint8_t quality;//0 - 63
|
||||
int8_t brightness;//-2 - 2
|
||||
int8_t contrast;//-2 - 2
|
||||
int8_t saturation;//-2 - 2
|
||||
int8_t sharpness;//-2 - 2
|
||||
uint8_t denoise;
|
||||
uint8_t special_effect;//0 - 6
|
||||
uint8_t wb_mode;//0 - 4
|
||||
uint8_t awb;
|
||||
uint8_t awb_gain;
|
||||
uint8_t aec;
|
||||
uint8_t aec2;
|
||||
int8_t ae_level;//-2 - 2
|
||||
uint16_t aec_value;//0 - 1200
|
||||
uint8_t agc;
|
||||
uint8_t agc_gain;//0 - 30
|
||||
uint8_t gainceiling;//0 - 6
|
||||
uint8_t bpc;
|
||||
uint8_t wpc;
|
||||
uint8_t raw_gma;
|
||||
uint8_t lenc;
|
||||
uint8_t hmirror;
|
||||
uint8_t vflip;
|
||||
uint8_t dcw;
|
||||
uint8_t colorbar;
|
||||
} camera_status_t;
|
||||
|
||||
typedef struct _sensor sensor_t;
|
||||
typedef struct _sensor {
|
||||
sensor_id_t id; // Sensor ID.
|
||||
uint8_t slv_addr; // Sensor I2C slave address.
|
||||
pixformat_t pixformat;
|
||||
camera_status_t status;
|
||||
int xclk_freq_hz;
|
||||
|
||||
// Sensor function pointers
|
||||
int (*init_status) (sensor_t *sensor);
|
||||
int (*reset) (sensor_t *sensor);
|
||||
int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat);
|
||||
int (*set_framesize) (sensor_t *sensor, framesize_t framesize);
|
||||
int (*set_contrast) (sensor_t *sensor, int level);
|
||||
int (*set_brightness) (sensor_t *sensor, int level);
|
||||
int (*set_saturation) (sensor_t *sensor, int level);
|
||||
int (*set_sharpness) (sensor_t *sensor, int level);
|
||||
int (*set_denoise) (sensor_t *sensor, int level);
|
||||
int (*set_gainceiling) (sensor_t *sensor, gainceiling_t gainceiling);
|
||||
int (*set_quality) (sensor_t *sensor, int quality);
|
||||
int (*set_colorbar) (sensor_t *sensor, int enable);
|
||||
int (*set_whitebal) (sensor_t *sensor, int enable);
|
||||
int (*set_gain_ctrl) (sensor_t *sensor, int enable);
|
||||
int (*set_exposure_ctrl) (sensor_t *sensor, int enable);
|
||||
int (*set_hmirror) (sensor_t *sensor, int enable);
|
||||
int (*set_vflip) (sensor_t *sensor, int enable);
|
||||
|
||||
int (*set_aec2) (sensor_t *sensor, int enable);
|
||||
int (*set_awb_gain) (sensor_t *sensor, int enable);
|
||||
int (*set_agc_gain) (sensor_t *sensor, int gain);
|
||||
int (*set_aec_value) (sensor_t *sensor, int gain);
|
||||
|
||||
int (*set_special_effect) (sensor_t *sensor, int effect);
|
||||
int (*set_wb_mode) (sensor_t *sensor, int mode);
|
||||
int (*set_ae_level) (sensor_t *sensor, int level);
|
||||
|
||||
int (*set_dcw) (sensor_t *sensor, int enable);
|
||||
int (*set_bpc) (sensor_t *sensor, int enable);
|
||||
int (*set_wpc) (sensor_t *sensor, int enable);
|
||||
|
||||
int (*set_raw_gma) (sensor_t *sensor, int enable);
|
||||
int (*set_lenc) (sensor_t *sensor, int enable);
|
||||
|
||||
int (*get_reg) (sensor_t *sensor, int reg, int mask);
|
||||
int (*set_reg) (sensor_t *sensor, int reg, int mask, int value);
|
||||
int (*set_res_raw) (sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning);
|
||||
int (*set_pll) (sensor_t *sensor, int bypass, int mul, int sys, int root, int pre, int seld5, int pclken, int pclk);
|
||||
int (*set_xclk) (sensor_t *sensor, int timer, int xclk);
|
||||
} sensor_t;
|
||||
|
||||
#endif /* __SENSOR_H__ */
|
@ -1,119 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_SSC_H__
|
||||
#define __ESP_SSC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CMD_T_ASYNC 0x01
|
||||
#define CMD_T_SYNC 0x02
|
||||
|
||||
typedef struct cmd_s {
|
||||
char *cmd_str;
|
||||
uint8_t flag;
|
||||
uint8_t id;
|
||||
void (* cmd_func)(void);
|
||||
void (* cmd_callback)(void *arg);
|
||||
} ssc_cmd_t;
|
||||
|
||||
#define MAX_LINE_N 127
|
||||
|
||||
typedef enum {
|
||||
SSC_BR_9600 = 9600,
|
||||
SSC_BR_19200 = 19200,
|
||||
SSC_BR_38400 = 38400,
|
||||
SSC_BR_57600 = 57600,
|
||||
SSC_BR_74880 = 74880,
|
||||
SSC_BR_115200 = 115200,
|
||||
SSC_BR_230400 = 230400,
|
||||
SSC_BR_460800 = 460800,
|
||||
SSC_BR_921600 = 921600
|
||||
} SscBaudRate;
|
||||
|
||||
/** \defgroup SSC_APIs SSC APIs
|
||||
* @brief SSC APIs
|
||||
*
|
||||
* SSC means simple serial command.
|
||||
* SSC APIs allows users to define their own command, users can refer to spiffs_test/test_main.c.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup SSC_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initial the ssc function.
|
||||
*
|
||||
* @attention param is no use, just compatible with ESP8266, default bandrate is 115200
|
||||
*
|
||||
* @param SscBaudRate bandrate : baud rate
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
void ssc_attach(SscBaudRate bandrate);
|
||||
|
||||
/**
|
||||
* @brief Get the length of the simple serial command.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return length of the command.
|
||||
*/
|
||||
int ssc_param_len(void);
|
||||
|
||||
/**
|
||||
* @brief Get the simple serial command string.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return the command.
|
||||
*/
|
||||
char *ssc_param_str(void);
|
||||
|
||||
/**
|
||||
* @brief Parse the simple serial command (ssc).
|
||||
*
|
||||
* @param char *pLine : [input] the ssc string
|
||||
* @param char *argv[] : [output] parameters of the ssc
|
||||
*
|
||||
* @return the number of parameters.
|
||||
*/
|
||||
int ssc_parse_param(char *pLine, char *argv[]);
|
||||
|
||||
/**
|
||||
* @brief Register the user-defined simple serial command (ssc) set.
|
||||
*
|
||||
* @param ssc_cmd_t *cmdset : the ssc set
|
||||
* @param uint8 cmdnum : number of commands
|
||||
* @param void (* help)(void) : callback of user-guide
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
void ssc_register(ssc_cmd_t *cmdset, uint8_t cmdnum, void (* help)(void));
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_SSC_H__ */
|
@ -86,6 +86,47 @@ typedef struct {
|
||||
*/
|
||||
esp_err_t (*on_lowlevel_deinit_done)(esp_eth_handle_t eth_handle);
|
||||
|
||||
/**
|
||||
* @brief Read PHY register
|
||||
*
|
||||
* @note Usually the PHY register read/write function is provided by MAC (SMI interface),
|
||||
* but if the PHY device is managed by other interface (e.g. I2C), then user needs to
|
||||
* implement the corresponding read/write.
|
||||
* Setting this to NULL means your PHY device is managed by MAC's SMI interface.
|
||||
*
|
||||
* @param[in] eth_handle: handle of Ethernet driver
|
||||
* @param[in] phy_addr: PHY chip address (0~31)
|
||||
* @param[in] phy_reg: PHY register index code
|
||||
* @param[out] reg_value: PHY register value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: read PHY register successfully
|
||||
* - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
|
||||
* - ESP_ERR_TIMEOUT: read PHY register failed because of timeout
|
||||
* - ESP_FAIL: read PHY register failed because some other error occurred
|
||||
*/
|
||||
esp_err_t (*read_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t *reg_value);
|
||||
|
||||
/**
|
||||
* @brief Write PHY register
|
||||
*
|
||||
* @note Usually the PHY register read/write function is provided by MAC (SMI interface),
|
||||
* but if the PHY device is managed by other interface (e.g. I2C), then user needs to
|
||||
* implement the corresponding read/write.
|
||||
* Setting this to NULL means your PHY device is managed by MAC's SMI interface.
|
||||
*
|
||||
* @param[in] eth_handle: handle of Ethernet driver
|
||||
* @param[in] phy_addr: PHY chip address (0~31)
|
||||
* @param[in] phy_reg: PHY register index code
|
||||
* @param[in] reg_value: PHY register value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: write PHY register successfully
|
||||
* - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
|
||||
* - ESP_ERR_TIMEOUT: write PHY register failed because of timeout
|
||||
* - ESP_FAIL: write PHY register failed because some other error occurred
|
||||
*/
|
||||
esp_err_t (*write_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t reg_value);
|
||||
} esp_eth_config_t;
|
||||
|
||||
/**
|
||||
@ -100,6 +141,8 @@ typedef struct {
|
||||
.stack_input = NULL, \
|
||||
.on_lowlevel_init_done = NULL, \
|
||||
.on_lowlevel_deinit_done = NULL, \
|
||||
.read_phy_reg = NULL, \
|
||||
.write_phy_reg = NULL, \
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -396,6 +396,39 @@ typedef struct {
|
||||
esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, const eth_mac_config_t *mac_config);
|
||||
#endif // CONFIG_ETH_SPI_ETHERNET_W5500
|
||||
|
||||
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
|
||||
/**
|
||||
* @brief KSZ8851SNL specific configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
void *spi_hdl; /*!< Handle of SPI device driver */
|
||||
int int_gpio_num; /*!< Interrupt GPIO number */
|
||||
} eth_ksz8851snl_config_t;
|
||||
|
||||
/**
|
||||
* @brief Default KSZ8851SNL specific configuration
|
||||
*
|
||||
*/
|
||||
#define ETH_KSZ8851SNL_DEFAULT_CONFIG(spi_device) \
|
||||
{ \
|
||||
.spi_hdl = spi_device, \
|
||||
.int_gpio_num = 14, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create KSZ8851SNL Ethernet MAC instance
|
||||
*
|
||||
* @param ksz8851snl_config: KSZ8851SNL specific configuration
|
||||
* @param mac_config: Ethernet MAC configuration
|
||||
*
|
||||
* @return
|
||||
* - instance: create MAC instance successfully
|
||||
* - NULL: create MAC instance failed because some error occurred
|
||||
*/
|
||||
esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851snl_config, const eth_mac_config_t *mac_config);
|
||||
#endif // CONFIG_ETH_SPI_ETHERNET_KSZ8851
|
||||
|
||||
#if CONFIG_ETH_USE_OPENETH
|
||||
/**
|
||||
* @brief Create OpenCores Ethernet MAC instance
|
||||
|
@ -300,6 +300,19 @@ esp_eth_phy_t *esp_eth_phy_new_dm9051(const eth_phy_config_t *config);
|
||||
*/
|
||||
esp_eth_phy_t *esp_eth_phy_new_w5500(const eth_phy_config_t *config);
|
||||
#endif
|
||||
|
||||
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
|
||||
/**
|
||||
* @brief Create a PHY instance of KSZ8851SNL
|
||||
*
|
||||
* @param[in] config: configuration of PHY
|
||||
*
|
||||
* @return
|
||||
* - instance: create PHY instance successfully
|
||||
* - NULL: create PHY instance failed because some error occurred
|
||||
*/
|
||||
esp_eth_phy_t *esp_eth_phy_new_ksz8851snl(const eth_phy_config_t *config);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -58,6 +58,7 @@ typedef enum {
|
||||
SYSTEM_EVENT_ETH_CONNECTED, /*!< ESP32 ethernet phy link up */
|
||||
SYSTEM_EVENT_ETH_DISCONNECTED, /*!< ESP32 ethernet phy link down */
|
||||
SYSTEM_EVENT_ETH_GOT_IP, /*!< ESP32 ethernet got IP from connected AP */
|
||||
SYSTEM_EVENT_ETH_LOST_IP, /*!< ESP32 ethernet lost IP and the IP is reset to 0 */
|
||||
SYSTEM_EVENT_MAX /*!< Number of members in this enum */
|
||||
} system_event_id_t;
|
||||
|
||||
|
@ -100,6 +100,7 @@ typedef union {
|
||||
|
||||
typedef struct {
|
||||
esp_event_handler_t callback;
|
||||
uint16_t event_stack_size;
|
||||
} esp_hidh_config_t;
|
||||
|
||||
/**
|
||||
|
@ -334,7 +334,7 @@ esp_err_t esp_http_client_get_password(esp_http_client_handle_t client, char **v
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_INVALID_ARG
|
||||
*/
|
||||
esp_err_t esp_http_client_set_password(esp_http_client_handle_t client, char *password);
|
||||
esp_err_t esp_http_client_set_password(esp_http_client_handle_t client, const char *password);
|
||||
|
||||
/**
|
||||
* @brief Set http request auth_type.
|
||||
@ -360,6 +360,18 @@ esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http
|
||||
*/
|
||||
esp_err_t esp_http_client_set_method(esp_http_client_handle_t client, esp_http_client_method_t method);
|
||||
|
||||
/**
|
||||
* @brief Set http request timeout
|
||||
*
|
||||
* @param[in] client The esp_http_client handle
|
||||
* @param[in] timeout_ms The timeout value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_INVALID_ARG
|
||||
*/
|
||||
esp_err_t esp_http_client_set_timeout_ms(esp_http_client_handle_t client, int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Delete http request header
|
||||
*
|
||||
|
@ -201,6 +201,21 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es
|
||||
*/
|
||||
int esp_https_ota_get_image_len_read(esp_https_ota_handle_t https_ota_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function returns OTA image total size.
|
||||
*
|
||||
* @note This API should be called after esp_https_ota_begin() has been already called.
|
||||
* This can be used to create some sort of progress indication
|
||||
* (in combination with esp_https_ota_get_image_len_read())
|
||||
*
|
||||
* @param[in] https_ota_handle pointer to esp_https_ota_handle_t structure
|
||||
*
|
||||
* @return
|
||||
* - -1 On failure or chunked encoding
|
||||
* - total bytes of image
|
||||
*/
|
||||
int esp_https_ota_get_image_size(esp_https_ota_handle_t https_ota_handle);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -47,17 +47,17 @@ typedef enum {
|
||||
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
||||
* external storage e.g. flash and EEPROM.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
||||
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
||||
* WiFi/BT/Ethernet.
|
||||
* Base MAC address is used to generate the MAC addresses used by network interfaces.
|
||||
*
|
||||
* If using a custom base MAC address, call this API before initializing any network interfaces.
|
||||
* Refer to the ESP-IDF Programming Guide for details about how the Base MAC is used.
|
||||
*
|
||||
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
||||
*
|
||||
* @note If not using a valid OUI, set the "locally administered" bit
|
||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||
@ -67,7 +67,9 @@ esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||
/**
|
||||
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
* @note If no custom Base MAC has been set, this returns the pre-programmed Espressif base MAC address.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
||||
@ -78,10 +80,14 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
||||
* This API returns the custom base MAC address which was previously written to EFUSE BLK3 in
|
||||
* a specified format.
|
||||
*
|
||||
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
||||
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
||||
*
|
||||
* @note This function is currently only supported on ESP32.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
@ -91,7 +97,7 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
||||
* @brief Return base MAC address which is factory-programmed by Espressif in EFUSE.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
@ -102,12 +108,12 @@ esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
/**
|
||||
* @brief Read base MAC address and set MAC address of the interface.
|
||||
*
|
||||
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
||||
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
||||
* bluetooth and ethernet.
|
||||
* This function first get base MAC address using esp_base_mac_addr_get().
|
||||
* Then calculates the MAC address of the specific interface requested,
|
||||
* refer to ESP-IDF Programming Guide for the algorithm.
|
||||
*
|
||||
* @param mac MAC address of the interface, length: 6 bytes.
|
||||
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||
* @param type Type of MAC address to return
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
@ -116,11 +122,13 @@ esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||
/**
|
||||
* @brief Derive local MAC address from universal MAC address.
|
||||
*
|
||||
* This function derives a local MAC address from an universal MAC address.
|
||||
* A `definition of local vs universal MAC address can be found on Wikipedia
|
||||
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
||||
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
||||
* Local MAC address is derived from the universal MAC address.
|
||||
* This function copies a universal MAC address and then sets the "locally
|
||||
* administered" bit (bit 0x2) in the first octet, creating a locally
|
||||
* administered MAC address.
|
||||
*
|
||||
* If the universal MAC address argument is already a locally administered MAC
|
||||
* address, then the first octet is XORed with 0x4 in order to create a different
|
||||
* locally administered MAC address.
|
||||
*
|
||||
* @param local_mac Derived local MAC address, length: 6 bytes.
|
||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||
|
@ -24,16 +24,27 @@ extern "C" {
|
||||
/**
|
||||
* @brief Get one random 32-bit word from hardware RNG
|
||||
*
|
||||
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
||||
* random values, call this function after WiFi or Bluetooth are started.
|
||||
* The hardware RNG produces true random numbers under any of the following conditions:
|
||||
*
|
||||
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
||||
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
||||
* documentation for more details.
|
||||
* - An RF subsystem is running (i.e. Bluetooth or WiFi is enabled)
|
||||
* - An internal entropy source has been enabled by calling bootloader_random_enable()
|
||||
* and not yet disabled by calling bootloader_random_disable()
|
||||
* - While the ESP-IDF bootloader is running (due to the internal entropy source being enabled
|
||||
* for the duration of bootloader execution).
|
||||
*
|
||||
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
||||
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
||||
* bootloader is running, but this should not be relied upon for any use.
|
||||
* If none of the above conditions are true, the hardware RNG will produce pseudo-random numbers only.
|
||||
*
|
||||
* When the hardware RNG is producing true random numbers, external entropy (noise samples) are
|
||||
* continuously mixed into the internal hardware RNG state. Consult the SoC Technical Reference Manual
|
||||
* for more details.
|
||||
*
|
||||
* This function automatically busy-waits to ensure enough external entropy has been
|
||||
* introduced into the hardware RNG state, before returning a new random number.
|
||||
*
|
||||
* If generating random numbers from an app which has not yet enabled Bluetooth or Wi-Fi, call the
|
||||
* API function bootloader_random_enable() before generating random numbers and then call
|
||||
* bootloader_random_disable() before using any APIs for Bluetooth, Wi-Fi, ADC, or I2S. Consult the
|
||||
* bootloader_random.h header for more details.
|
||||
*
|
||||
* @return Random value between 0 and UINT32_MAX
|
||||
*/
|
||||
|
@ -303,6 +303,12 @@ esp_err_t esp_sleep_enable_uart_wakeup(int uart_num);
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_wifi_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Disable wakeup by WiFi MAC
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_sleep_disable_wifi_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (ext1)
|
||||
|
@ -45,20 +45,45 @@ void i2c_rtc_write_reg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t
|
||||
void i2c_rtc_write_reg_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data);
|
||||
void i2c_rtc_init(void);
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
|
||||
/**
|
||||
* If compiling for the bootloader, internal functions can be called directly,
|
||||
* without the need of a lock.
|
||||
*/
|
||||
#define regi2c_ctrl_read_reg i2c_rtc_read_reg
|
||||
#define regi2c_ctrl_read_reg_mask i2c_rtc_read_reg_mask
|
||||
#define regi2c_ctrl_write_reg i2c_rtc_write_reg
|
||||
#define regi2c_ctrl_write_reg_mask i2c_rtc_write_reg_mask
|
||||
|
||||
#else
|
||||
|
||||
#define i2c_read_reg_raw i2c_rtc_read_reg
|
||||
#define i2c_read_reg_mask_raw i2c_rtc_read_reg_mask
|
||||
#define i2c_write_reg_raw i2c_rtc_write_reg
|
||||
#define i2c_write_reg_mask_raw i2c_rtc_write_reg_mask
|
||||
|
||||
uint8_t regi2c_ctrl_read_reg(uint8_t block, uint8_t host_id, uint8_t reg_add);
|
||||
uint8_t regi2c_ctrl_read_reg_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb);
|
||||
void regi2c_ctrl_write_reg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data);
|
||||
void regi2c_ctrl_write_reg_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data);
|
||||
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
/* Convenience macros for the above functions, these use register definitions
|
||||
* from regi2c_apll.h/regi2c_bbpll.h header files.
|
||||
*/
|
||||
#define REGI2C_WRITE_MASK(block, reg_add, indata) \
|
||||
i2c_rtc_write_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata)
|
||||
regi2c_ctrl_write_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata)
|
||||
|
||||
#define REGI2C_READ_MASK(block, reg_add) \
|
||||
i2c_rtc_read_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB)
|
||||
regi2c_ctrl_read_reg_mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB)
|
||||
|
||||
#define REGI2C_WRITE(block, reg_add, indata) \
|
||||
i2c_rtc_write_reg(block, block##_HOSTID, reg_add, indata)
|
||||
regi2c_ctrl_write_reg(block, block##_HOSTID, reg_add, indata)
|
||||
|
||||
#define REGI2C_READ(block, reg_add) \
|
||||
i2c_rtc_read_reg(block, block##_HOSTID, reg_add)
|
||||
regi2c_ctrl_read_reg(block, block##_HOSTID, reg_add)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
201
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h
Normal file
201
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_types.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD SPI bus handle */
|
||||
typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */
|
||||
typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */
|
||||
|
||||
/**
|
||||
* @brief Transmit LCD command and corresponding parameters
|
||||
*
|
||||
* @note Commands sent by this function are short, so they are sent using polling transactions.
|
||||
* The function does not return before the command tranfer is completed.
|
||||
* If any queued transactions sent by `esp_lcd_panel_io_tx_color()` are still pending when this function is called,
|
||||
* this function will wait until they are finished and the queue is empty before sending the command(s).
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @param[in] lcd_cmd The specific LCD command
|
||||
* @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits)
|
||||
* @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command
|
||||
* @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size);
|
||||
|
||||
/**
|
||||
* @brief Transmit LCD RGB data
|
||||
*
|
||||
* @note This function will package the command and RGB data into a transaction, and push into a queue.
|
||||
* The real transmission is performed in the background (DMA+interrupt).
|
||||
* The caller should take care of the lifecycle of the `color` buffer.
|
||||
* Recycling of color buffer should be done in the callback `on_color_trans_done()`.
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @param[in] lcd_cmd The specific LCD command
|
||||
* @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits)
|
||||
* @param[in] color Buffer that holds the RGB color data
|
||||
* @param[in] color_size Size of `color` in memory, in bytes
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size);
|
||||
|
||||
/**
|
||||
* @brief Destory LCD panel IO handle (deinitialize panel and free all corresponding resource)
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_io_del(esp_lcd_panel_io_handle_t io);
|
||||
|
||||
/**
|
||||
* @brief Panel IO configuration structure, for SPI interface
|
||||
*/
|
||||
typedef struct {
|
||||
int cs_gpio_num; /*!< GPIO used for CS line */
|
||||
int dc_gpio_num; /*!< GPIO used to select the D/C line, set this to -1 if the D/C line not controlled by manually pulling high/low GPIO */
|
||||
int spi_mode; /*!< Traditional SPI mode (0~3) */
|
||||
unsigned int pclk_hz; /*!< Frequency of pixel clock */
|
||||
size_t trans_queue_depth; /*!< Size of internal transaction queue */
|
||||
bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data transfer has finished */
|
||||
void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */
|
||||
struct {
|
||||
unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */
|
||||
unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */
|
||||
} flags;
|
||||
} esp_lcd_panel_io_spi_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel IO handle, for SPI interface
|
||||
*
|
||||
* @param[in] bus SPI bus handle
|
||||
* @param[in] io_config IO configuration, for SPI interface
|
||||
* @param[out] ret_io Returned IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_panel_io_spi_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
|
||||
|
||||
typedef struct {
|
||||
uint32_t dev_addr; /*!< I2C device address */
|
||||
bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data transfer has finished */
|
||||
void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */
|
||||
size_t control_phase_bytes; /*!< I2C LCD panel will encode control information (e.g. D/C seclection) into control phase, in several bytes */
|
||||
unsigned int dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */
|
||||
struct {
|
||||
unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */
|
||||
} flags;
|
||||
} esp_lcd_panel_io_i2c_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel IO handle, for I2C interface
|
||||
*
|
||||
* @param[in] bus I2C bus handle
|
||||
* @param[in] io_config IO configuration, for I2C interface
|
||||
* @param[out] ret_io Returned IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_io_i2c(esp_lcd_i2c_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
|
||||
|
||||
#if SOC_LCD_I80_SUPPORTED
|
||||
/**
|
||||
* @brief LCD Intel 8080 bus configuration structure
|
||||
*/
|
||||
typedef struct {
|
||||
int dc_gpio_num; /*!< GPIO used for D/C line */
|
||||
int wr_gpio_num; /*!< GPIO used for WR line */
|
||||
int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */
|
||||
size_t data_width; /*!< Number of data lines, 8 or 16 */
|
||||
size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */
|
||||
} esp_lcd_i80_bus_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create Intel 8080 bus handle
|
||||
*
|
||||
* @param[in] bus_config Bus configuration
|
||||
* @param[out] ret_bus Returned bus handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_ERR_NOT_FOUND if no free bus is available
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lcd_i80_bus_handle_t *ret_bus);
|
||||
|
||||
/**
|
||||
* @brief Destory Intel 8080 bus handle
|
||||
*
|
||||
* @param[in] bus Intel 8080 bus handle, created by `esp_lcd_new_i80_bus()`
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_INVALID_STATE if there still be some device attached to the bus
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus);
|
||||
|
||||
/**
|
||||
* @brief Panel IO configuration structure, for intel 8080 interface
|
||||
*/
|
||||
typedef struct {
|
||||
int cs_gpio_num; /*!< GPIO used for CS line */
|
||||
unsigned int pclk_hz; /*!< Frequency of pixel clock */
|
||||
size_t trans_queue_depth; /*!< Transaction queue size, larger queue, higher throughput */
|
||||
bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data was tranferred done */
|
||||
void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */
|
||||
struct {
|
||||
unsigned int dc_idle_level: 1; /*!< Level of DC line in IDLE phase */
|
||||
unsigned int dc_cmd_level: 1; /*!< Level of DC line in CMD phase */
|
||||
unsigned int dc_dummy_level: 1; /*!< Level of DC line in DUMMY phase */
|
||||
unsigned int dc_data_level: 1; /*!< Level of DC line in DATA phase */
|
||||
} dc_levels; /*!< Each i80 device might have its own D/C control logic */
|
||||
struct {
|
||||
unsigned int invert_cs: 1; /*!< Whether to invert the CS line */
|
||||
unsigned int reverse_color_bits: 1; /*!< Reverse the data bits, D[N:0] -> D[0:N] */
|
||||
unsigned int swap_color_bytes: 1; /*!< Swap adjacent two color bytes */
|
||||
unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on WR signal (a.k.a the PCLK) */
|
||||
unsigned int pclk_idle_low: 1; /*!< The WR signal (a.k.a the PCLK) stays at low level in IDLE phase */
|
||||
} flags;
|
||||
} esp_lcd_panel_io_i80_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel IO, for Intel 8080 interface
|
||||
*
|
||||
* @param[in] bus Intel 8080 bus handle, created by `esp_lcd_new_i80_bus()`
|
||||
* @param[in] io_config IO configuration, for i80 interface
|
||||
* @param[out] ret_io Returned panel IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NOT_SUPPORTED if some configuration can't be satisfied, e.g. pixel clock out of the range
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_io_i80(esp_lcd_i80_bus_handle_t bus, const esp_lcd_panel_io_i80_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
|
||||
|
||||
#endif // SOC_LCD_I80_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
126
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_ops.h
Normal file
126
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_ops.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reset LCD panel
|
||||
*
|
||||
* @note Panel reset must be called before attempting to initialize the panel using `esp_lcd_panel_init()`.
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_reset(esp_lcd_panel_handle_t panel);
|
||||
|
||||
/**
|
||||
* @brief Initialize LCD panel
|
||||
*
|
||||
* @note Before calling this function, make sure the LCD panel has finished the `reset` stage by `esp_lcd_panel_reset()`.
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_init(esp_lcd_panel_handle_t panel);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_del(esp_lcd_panel_handle_t panel);
|
||||
|
||||
/**
|
||||
* @brief Draw bitmap on LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] x_start Start index on x-axis (x_start included)
|
||||
* @param[in] y_start Start index on y-axis (y_start included)
|
||||
* @param[in] x_end End index on x-axis (x_end not included)
|
||||
* @param[in] y_end End index on y-axis (y_end not included)
|
||||
* @param[in] color_data RGB color data that will be dumped to the specific window range
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_draw_bitmap(esp_lcd_panel_handle_t panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
||||
|
||||
/**
|
||||
* @brief Mirror the LCD panel on specific axis
|
||||
*
|
||||
* @note Combined with `esp_lcd_panel_swap_xy()`, one can realize screen rotation
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] mirror_x Whether the panel will be mirrored about the x axis
|
||||
* @param[in] mirror_y Whether the panel will be mirrored about the y axis
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_mirror(esp_lcd_panel_handle_t panel, bool mirror_x, bool mirror_y);
|
||||
|
||||
/**
|
||||
* @brief Swap/Exchange x and y axis
|
||||
*
|
||||
* @note Combined with `esp_lcd_panel_mirror()`, one can realize screen rotation
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] swap_axes Whether to swap the x and y axis
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_swap_xy(esp_lcd_panel_handle_t panel, bool swap_axes);
|
||||
|
||||
/**
|
||||
* @brief Set extra gap in x and y axis
|
||||
*
|
||||
* The gap is the space (in pixels) between the left/top sides of the LCD panel and the first row/column respectively of the actual contents displayed.
|
||||
*
|
||||
* @note Setting a gap is useful when positioning or centering a frame that is smaller than the LCD.
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] x_gap Extra gap on x axis, in pixels
|
||||
* @param[in] y_gap Extra gap on y axis, in pixels
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_set_gap(esp_lcd_panel_handle_t panel, int x_gap, int y_gap);
|
||||
|
||||
/**
|
||||
* @brief Invert the color (bit-wise invert the color data line)
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] invert_color_data Whether to invert the color data
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_invert_color(esp_lcd_panel_handle_t panel, bool invert_color_data);
|
||||
|
||||
/**
|
||||
* @brief Turn off the display
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] off Whether to turn off the screen
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_types.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if SOC_LCD_RGB_SUPPORTED
|
||||
/**
|
||||
* @brief LCD RGB timing structure
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int pclk_hz; /*!< Frequency of pixel clock */
|
||||
unsigned int h_res; /*!< Horizontal resolution, i.e. the number of pixels in a line */
|
||||
unsigned int v_res; /*!< Vertical resolution, i.e. the number of lines in the frame */
|
||||
unsigned int hsync_pulse_width; /*!< Horizontal sync width, unit: PCLK period */
|
||||
unsigned int hsync_back_porch; /*!< Horizontal back porch, number of PCLK between hsync and start of line active data */
|
||||
unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */
|
||||
unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */
|
||||
unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */
|
||||
unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */
|
||||
struct {
|
||||
unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */
|
||||
unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */
|
||||
unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */
|
||||
unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on PCLK */
|
||||
unsigned int pclk_idle_low: 1; /*!< The PCLK stays at low level in IDLE phase */
|
||||
} flags;
|
||||
} esp_lcd_rgb_timing_t;
|
||||
|
||||
/**
|
||||
* @brief LCD RGB panel configuration structure
|
||||
*/
|
||||
typedef struct {
|
||||
esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */
|
||||
size_t data_width; /*!< Number of data lines */
|
||||
int hsync_gpio_num; /*!< GPIO used for HSYNC signal */
|
||||
int vsync_gpio_num; /*!< GPIO used for VSYNC signal */
|
||||
int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */
|
||||
int pclk_gpio_num; /*!< GPIO used for PCLK signal */
|
||||
int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */
|
||||
int disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */
|
||||
bool (*on_frame_trans_done)(esp_lcd_panel_handle_t panel, void *user_data); /*!< Callback, invoked when one frame buffer has transferred done */
|
||||
void *user_data; /*!< User data which would be passed to on_frame_trans_done's user_data */
|
||||
struct {
|
||||
unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */
|
||||
unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */
|
||||
} flags;
|
||||
} esp_lcd_rgb_panel_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create RGB LCD panel
|
||||
*
|
||||
* @param rgb_panel_config RGB panel configuration
|
||||
* @param ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_ERR_NOT_FOUND if no free RGB panel is available
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
#endif // SOC_LCD_RGB_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration structure for panel device
|
||||
*/
|
||||
typedef struct {
|
||||
int reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */
|
||||
esp_lcd_color_space_t color_space; /*!< Set the color space used by the LCD panel */
|
||||
unsigned int bits_per_pixel; /*!< Color depth, in bpp */
|
||||
struct {
|
||||
unsigned int reset_active_high: 1; /*!< Setting this if the panel reset is high level active */
|
||||
} flags;
|
||||
void *vendor_config; /* vendor specific configuration, optional, left as NULL if not used */
|
||||
} esp_lcd_panel_dev_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model ST7789
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config general panel device configuration
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model SSD1306
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config general panel device configuration
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_ssd1306(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
26
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_types.h
Normal file
26
tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_types.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct esp_lcd_panel_io_t *esp_lcd_panel_io_handle_t; /*!< Type of LCD panel IO handle */
|
||||
typedef struct esp_lcd_panel_t *esp_lcd_panel_handle_t; /*!< Type of LCD panel handle */
|
||||
|
||||
/**
|
||||
* @brief LCD color space type definition
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_LCD_COLOR_SPACE_RGB, /*!< Color space: RGB */
|
||||
ESP_LCD_COLOR_SPACE_BGR, /*!< Color space: BGR */
|
||||
ESP_LCD_COLOR_SPACE_MONOCHROME, /*!< Color space: monochrome */
|
||||
} esp_lcd_color_space_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct esp_lcd_panel_t esp_lcd_panel_t; /*!< Type of LCD panel */
|
||||
|
||||
/**
|
||||
* @brief LCD panel interface
|
||||
*/
|
||||
struct esp_lcd_panel_t {
|
||||
/**
|
||||
* @brief Reset LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*reset)(esp_lcd_panel_t *panel);
|
||||
|
||||
/**
|
||||
* @brief Initialize LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*init)(esp_lcd_panel_t *panel);
|
||||
|
||||
/**
|
||||
* @brief Destory LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*del)(esp_lcd_panel_t *panel);
|
||||
|
||||
/**
|
||||
* @brief Draw bitmap on LCD panel
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] x_start Start index on x-axis (x_start included)
|
||||
* @param[in] y_start Start index on y-axis (y_start included)
|
||||
* @param[in] x_end End index on x-axis (x_end not included)
|
||||
* @param[in] y_end End index on y-axis (y_end not included)
|
||||
* @param[in] color_data RGB color data that will be dumped to the specific window range
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*draw_bitmap)(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
||||
|
||||
/**
|
||||
* @brief Mirror the LCD panel on specific axis
|
||||
*
|
||||
* @note Combine this function with `swap_xy`, one can realize screen rotatation
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] x_axis Whether the panel will be mirrored about the x_axis
|
||||
* @param[in] y_axis Whether the panel will be mirrored about the y_axis
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t (*mirror)(esp_lcd_panel_t *panel, bool x_axis, bool y_axis);
|
||||
|
||||
/**
|
||||
* @brief Swap/Exchange x and y axis
|
||||
*
|
||||
* @note Combine this function with `mirror`, one can realize screen rotatation
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] swap_axes Whether to swap the x and y axis
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t (*swap_xy)(esp_lcd_panel_t *panel, bool swap_axes);
|
||||
|
||||
/**
|
||||
* @brief Set extra gap in x and y axis
|
||||
*
|
||||
* @note The gap is only used for calculating the real coordinates.
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] x_gap Extra gap on x axis, in pixels
|
||||
* @param[in] y_gap Extra gap on y axis, in pixels
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*set_gap)(esp_lcd_panel_t *panel, int x_gap, int y_gap);
|
||||
|
||||
/**
|
||||
* @brief Invert the color (bit 1 -> 0 for color data line, and vice versa)
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] invert_color_data Whether to invert the color data
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*invert_color)(esp_lcd_panel_t *panel, bool invert_color_data);
|
||||
|
||||
/**
|
||||
* @brief Turn off the display
|
||||
*
|
||||
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
|
||||
* @param[in] off Whether to turn off the screen
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
|
||||
*/
|
||||
esp_err_t (*disp_off)(esp_lcd_panel_t *panel, bool off);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct esp_lcd_panel_io_t esp_lcd_panel_io_t; /*!< Type of LCD panel IO */
|
||||
|
||||
/**
|
||||
* @brief LCD panel IO interface
|
||||
*/
|
||||
struct esp_lcd_panel_io_t {
|
||||
/**
|
||||
* @brief Transmit LCD command and corresponding parameters
|
||||
*
|
||||
* @note This is the panel-specific interface called by function `esp_lcd_panel_io_tx_param()`.
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @param[in] lcd_cmd The specific LCD command
|
||||
* @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits)
|
||||
* @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command
|
||||
* @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size);
|
||||
|
||||
/**
|
||||
* @brief Transmit LCD RGB data
|
||||
*
|
||||
* @note This is the panel-specific interface called by function `esp_lcd_panel_io_tx_color()`.
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @param[in] lcd_cmd The specific LCD command
|
||||
* @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits)
|
||||
* @param[in] color Buffer that holds the RGB color data
|
||||
* @param[in] color_size Size of `color` in memory, in bytes
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size);
|
||||
|
||||
/**
|
||||
* @brief Destory LCD panel IO handle (deinitialize all and free resource)
|
||||
*
|
||||
* @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()`
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t (*del)(esp_lcd_panel_io_t *io);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -55,7 +55,7 @@ extern "C" {
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
||||
.get_ip_event = IP_EVENT_ETH_GOT_IP, \
|
||||
.lost_ip_event = 0, \
|
||||
.lost_ip_event = IP_EVENT_ETH_LOST_IP, \
|
||||
.if_key = "ETH_DEF", \
|
||||
.if_desc = "eth", \
|
||||
.route_prio = 50 \
|
||||
|
@ -88,6 +88,7 @@ typedef enum {
|
||||
IP_EVENT_AP_STAIPASSIGNED, /*!< soft-AP assign an IP to a connected station */
|
||||
IP_EVENT_GOT_IP6, /*!< station or ap or ethernet interface v6IP addr is preferred */
|
||||
IP_EVENT_ETH_GOT_IP, /*!< ethernet got IP from connected AP */
|
||||
IP_EVENT_ETH_LOST_IP, /*!< ethernet lost IP and the IP is reset to 0 */
|
||||
IP_EVENT_PPP_GOT_IP, /*!< PPP interface got IP */
|
||||
IP_EVENT_PPP_LOST_IP, /*!< PPP interface lost IP */
|
||||
} ip_event_t;
|
||||
|
@ -191,7 +191,7 @@ int ets_printf(const char *fmt, ...);
|
||||
* @brief Set the uart channel of ets_printf(uart_tx_one_char).
|
||||
* ROM will set it base on the efuse and gpio setting, however, this can be changed after booting.
|
||||
*
|
||||
* @param uart_no : 0 for UART0, 1 for UART1, 2 for UART2.
|
||||
* @param uart_no : 0 for UART0, 1 for UART1.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
|
@ -260,7 +260,7 @@ void uart_tx_flush(uint8_t uart_no);
|
||||
/**
|
||||
* @brief Wait until uart tx full empty and the last char send ok.
|
||||
*
|
||||
* @param uart_no : 0 for UART0, 1 for UART1, 2 for UART2
|
||||
* @param uart_no : 0 for UART0, 1 for UART1
|
||||
*
|
||||
* The function defined in ROM code has a bug, so we define the correct version
|
||||
* here for compatibility.
|
||||
|
@ -28,7 +28,7 @@ extern "C"
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Read the shared buffer from the slave.
|
||||
* @brief Read the shared buffer from the slave in ISR way
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
@ -46,7 +46,25 @@ extern "C"
|
||||
esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Write the shared buffer of the slave.
|
||||
* @brief Read the shared buffer from the slave in polling way
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
* overwritten, even the ``len`` is shorter than a word.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4
|
||||
* @param addr Address of the slave shared buffer
|
||||
* @param len Length to read
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: on success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_rdbuf_polling(spi_device_handle_t spi, uint8_t *out_data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Write the shared buffer of the slave in ISR way
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
@ -63,6 +81,24 @@ esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, i
|
||||
*/
|
||||
esp_err_t essl_spi_wrbuf(spi_device_handle_t spi, const uint8_t *data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Write the shared buffer of the slave in polling way
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
* overwritten, even the ``len`` is shorter than a word.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4
|
||||
* @param addr Address of the slave shared buffer,
|
||||
* @param len Length to write
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_polling_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_wrbuf_polling(spi_device_handle_t spi, const uint8_t *data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Receive long buffer in segments from the slave through its DMA.
|
||||
*
|
||||
|
@ -655,7 +655,7 @@ esp_err_t esp_mesh_stop(void);
|
||||
* - If the packet is to the root ("to" parameter isn't NULL) or to external IP network, MESH_DATA_TODS should be set.
|
||||
* - If the packet is from the root to an internal device, MESH_DATA_FROMDS should be set.
|
||||
* - Specify whether this API is block or non-block, block by default
|
||||
* - If needs non-block, MESH_DATA_NONBLOCK should be set.
|
||||
* - If needs non-blocking, MESH_DATA_NONBLOCK should be set. Otherwise, may use esp_mesh_send_block_time() to specify a blocking time.
|
||||
* - In the situation of the root change, MESH_DATA_DROP identifies this packet can be dropped by the new root
|
||||
* for upstream data to external IP network, we try our best to avoid data loss caused by the root change, but
|
||||
* there is a risk that the new root is running out of memory because most of memory is occupied by the pending data which
|
||||
@ -688,6 +688,17 @@ esp_err_t esp_mesh_stop(void);
|
||||
*/
|
||||
esp_err_t esp_mesh_send(const mesh_addr_t *to, const mesh_data_t *data,
|
||||
int flag, const mesh_opt_t opt[], int opt_count);
|
||||
/**
|
||||
* @brief Set blocking time of esp_mesh_send()
|
||||
*
|
||||
* @attention This API shall be called before mesh is started.
|
||||
*
|
||||
* @param[in] time_ms blocking time of esp_mesh_send(), unit:ms
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_send_block_time(uint32_t time_ms);
|
||||
|
||||
/**
|
||||
* @brief Receive a packet targeted to self over the mesh network
|
||||
@ -1665,7 +1676,6 @@ int esp_mesh_get_running_active_duty_cycle(void);
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_ps_duty_signaling(int fwd_times);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -72,17 +72,6 @@ typedef enum {
|
||||
WIFI_LOG_MODULE_MESH, /*logs related to Mesh*/
|
||||
} wifi_log_module_t;
|
||||
|
||||
/**
|
||||
* @brief FTM Report log levels configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t show_rtt:1; /**< Display all valid Round-Trip-Time readings for FTM frames */
|
||||
uint8_t show_diag:1; /**< Display dialogue tokens for all FTM frames with valid readings */
|
||||
uint8_t show_t1t2t3t4:1;/**< Display all valid T1, T2, T3, T4 readings considered while calculating RTT */
|
||||
uint8_t show_rxrssi:1; /**< Display RSSI for each FTM frame with valid readings */
|
||||
} ftm_report_log_level_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi log submodule definition
|
||||
*
|
||||
@ -598,17 +587,6 @@ void esp_wifi_set_sleep_delay_time(uint32_t return_to_sleep_delay);
|
||||
*/
|
||||
void esp_wifi_set_keep_alive_time(uint32_t keep_alive_time);
|
||||
|
||||
/**
|
||||
* @brief Set FTM Report log level
|
||||
*
|
||||
* @param log_lvl Log levels configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_NOT_SUPPORTED: No FTM support
|
||||
*/
|
||||
esp_err_t esp_wifi_set_ftm_report_log_level(ftm_report_log_level_t *log_lvl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -70,6 +70,9 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif);
|
||||
/**
|
||||
* @brief Creates default WIFI AP. In case of any init error this API aborts.
|
||||
*
|
||||
* @note The API creates esp_netif object with default WiFi access point config,
|
||||
* attaches the netif to wifi and registers default wifi handlers.
|
||||
*
|
||||
* @return pointer to esp-netif instance
|
||||
*/
|
||||
esp_netif_t* esp_netif_create_default_wifi_ap(void);
|
||||
@ -77,10 +80,23 @@ esp_netif_t* esp_netif_create_default_wifi_ap(void);
|
||||
/**
|
||||
* @brief Creates default WIFI STA. In case of any init error this API aborts.
|
||||
*
|
||||
* @note The API creates esp_netif object with default WiFi station config,
|
||||
* attaches the netif to wifi and registers default wifi handlers.
|
||||
*
|
||||
* @return pointer to esp-netif instance
|
||||
*/
|
||||
esp_netif_t* esp_netif_create_default_wifi_sta(void);
|
||||
|
||||
/**
|
||||
* @brief Destroys default WIFI netif created with esp_netif_create_default_wifi_...() API.
|
||||
*
|
||||
* @param[in] esp_netif object to detach from WiFi and destroy
|
||||
*
|
||||
* @note This API unregisters wifi handlers and detaches the created object from the wifi.
|
||||
* (this function is a no-operation if esp_netif is NULL)
|
||||
*/
|
||||
void esp_netif_destroy_default_wifi(void *esp_netif);
|
||||
|
||||
/**
|
||||
* @brief Creates esp_netif WiFi object based on the custom configuration.
|
||||
*
|
||||
|
@ -233,6 +233,7 @@ typedef struct {
|
||||
uint8_t max_connection; /**< Max number of stations allowed to connect in, default 4, max 10 */
|
||||
uint16_t beacon_interval; /**< Beacon interval which should be multiples of 100. Unit: TU(time unit, 1 TU = 1024 us). Range: 100 ~ 60000. Default value: 100 */
|
||||
wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of SoftAP, group cipher will be derived using this. cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */
|
||||
bool ftm_responder; /**< Enable FTM Responder mode */
|
||||
} wifi_ap_config_t;
|
||||
|
||||
/** @brief STA configuration settings for the ESP32 */
|
||||
|
@ -104,6 +104,19 @@ void esp_core_dump_to_uart(panic_info_t *info);
|
||||
/*********************************** USER MODE API ************************************/
|
||||
/**************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Check integrity of coredump data in flash.
|
||||
* This function reads the coredump data while calculating their checksum. If it
|
||||
* doesn't match the checksum written on flash, it means data are corrupted,
|
||||
* an error will be returned. Else, ESP_OK is returned.
|
||||
*
|
||||
* @return `ESP_OK` if core dump is present and valid, `ESP_ERR_NOT_FOUND` if no core dump
|
||||
* is stored in the partition, `ESP_ERR_INVALID_SIZE` or `ESP_ERR_INVALID_CRC`
|
||||
* if the core dump is corrupted, other errors when unable to access flash, in that
|
||||
* case please refer to \see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_core_dump_image_check(void);
|
||||
|
||||
/**
|
||||
* @brief Retrieves address and size of coredump data in flash.
|
||||
* This function is always available, even when core dump is disabled in menuconfig.
|
||||
|
@ -165,7 +165,7 @@ static inline bool cpu_ll_is_debugger_attached(void)
|
||||
|
||||
static inline void cpu_ll_break(void)
|
||||
{
|
||||
__asm__ ("break 0,0");
|
||||
__asm__ ("break 1,15");
|
||||
}
|
||||
|
||||
static inline void cpu_ll_set_vecbase(const void* vecbase)
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc.h"
|
||||
#include "xtensa/xtensa_api.h"
|
||||
#include "xtensa/config/specreg.h"
|
||||
#include "xt_instr_macros.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -43,6 +45,18 @@ static inline void intr_cntrl_ll_disable_interrupts(uint32_t mask)
|
||||
xt_ints_off(mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the current interrupt mask of the CPU running this code.
|
||||
*
|
||||
* @return The current interrupt bitmask.
|
||||
*/
|
||||
static inline uint32_t intr_cntrl_ll_read_interrupt_mask(void)
|
||||
{
|
||||
uint32_t int_mask;
|
||||
RSR(INTENABLE, int_mask);
|
||||
return int_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checks if given interrupt number has a valid handler
|
||||
*
|
||||
@ -79,27 +93,6 @@ static inline void *intr_cntrl_ll_get_int_handler_arg(uint8_t intr)
|
||||
return xt_get_interrupt_handler_arg(intr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables interrupts that are not located in iram
|
||||
*
|
||||
* @param newmask mask of interrupts needs to be disabled
|
||||
* @return oldmask where to store old interrupts state
|
||||
*/
|
||||
static inline uint32_t intr_cntrl_ll_disable_int_mask(uint32_t newmask)
|
||||
{
|
||||
return xt_int_disable_mask(newmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enables interrupts that are not located in iram
|
||||
*
|
||||
* @param newmask mask of interrupts needs to be disabled
|
||||
*/
|
||||
static inline void intr_cntrl_ll_enable_int_mask(uint32_t newmask)
|
||||
{
|
||||
xt_int_enable_mask(newmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Acknowledge an edge-trigger interrupt by clearing its pending flag
|
||||
*
|
||||
|
@ -22,7 +22,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline uint32_t mpu_ll_id_to_addr(int id)
|
||||
static inline uint32_t mpu_ll_id_to_addr(unsigned id)
|
||||
{
|
||||
// vpn - id
|
||||
// 0x00000000 = 0
|
||||
|
@ -0,0 +1,166 @@
|
||||
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The ll is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The Lowlevel layer for SPI Flash Encryption.
|
||||
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/hwcrypto_reg.h"
|
||||
#include "soc/soc.h"
|
||||
#include "string.h"
|
||||
#include "assert.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// Choose type of chip you want to encrypt manully
|
||||
typedef enum
|
||||
{
|
||||
FLASH_ENCRYPTION_MANU = 0, ///!< Manually encrypt the flash chip.
|
||||
PSRAM_ENCRYPTION_MANU = 1 ///!< Manually encrypt the psram chip.
|
||||
} flash_encrypt_ll_type_t;
|
||||
|
||||
/**
|
||||
* Enable the flash encryption function under spi boot mode and download boot mode.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_enable(void)
|
||||
{
|
||||
REG_SET_BIT(DPORT_EXTERNAL_DEVICE_ENCRYPT_DECRYPT_CONTROL_REG,
|
||||
DPORT_ENABLE_DOWNLOAD_MANUAL_ENCRYPT |
|
||||
DPORT_ENABLE_SPI_MANUAL_ENCRYPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the AES accelerator.
|
||||
* Also clear reset on digital signature unit, otherwise AES is held in resetop.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_aes_accelerator_enable(void)
|
||||
{
|
||||
REG_SET_BIT(DPORT_CPU_PERIP_CLK_EN1_REG, DPORT_CRYPTO_AES_CLK_EN);
|
||||
REG_CLR_BIT(DPORT_CPU_PERIP_RST_EN1_REG, DPORT_CRYPTO_AES_RST | DPORT_CRYPTO_DS_RST);
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the flash encryption mode.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_disable(void)
|
||||
{
|
||||
REG_CLR_BIT(DPORT_EXTERNAL_DEVICE_ENCRYPT_DECRYPT_CONTROL_REG,
|
||||
DPORT_ENABLE_SPI_MANUAL_ENCRYPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose type of chip you want to encrypt manully
|
||||
*
|
||||
* @param type The type of chip to be encrypted
|
||||
*
|
||||
* @note The hardware currently support flash encryption.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_type(flash_encrypt_ll_type_t type)
|
||||
{
|
||||
// Our hardware only support flash encryption
|
||||
assert(type == FLASH_ENCRYPTION_MANU);
|
||||
REG_WRITE(AES_XTS_DESTINATION_REG, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the data size of a single encryption.
|
||||
*
|
||||
* @param block_size Size of the desired block.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_buffer_length(uint32_t size)
|
||||
{
|
||||
// Desired block should not be larger than the block size.
|
||||
REG_WRITE(AES_XTS_SIZE_REG, size >> 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save 32-bit piece of plaintext.
|
||||
*
|
||||
* @param address the address of written flash partition.
|
||||
* @param buffer Buffer to store the input data.
|
||||
* @param size Buffer size.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_plaintext_save(uint32_t address, const uint32_t* buffer, uint32_t size)
|
||||
{
|
||||
uint32_t plaintext_offs = (address % 64);
|
||||
memcpy((void *)(AES_XTS_PLAIN_BASE + plaintext_offs), buffer, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the flash address to XTS_AES physical address
|
||||
*
|
||||
* @param flash_addr flash address to write.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_address_save(uint32_t flash_addr)
|
||||
{
|
||||
REG_WRITE(AES_XTS_PHYSICAL_ADDR_REG, flash_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start flash encryption
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_calculate_start(void)
|
||||
{
|
||||
REG_WRITE(AES_XTS_TRIGGER_REG, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for flash encryption termination
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_calculate_wait_idle(void)
|
||||
{
|
||||
while(REG_READ(AES_XTS_STATE_REG) == 0x1) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish the flash encryption and make encrypted result accessible to SPI.
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_done(void)
|
||||
{
|
||||
REG_WRITE(AES_XTS_RELEASE_REG, 1);
|
||||
while(REG_READ(AES_XTS_STATE_REG) != 0x3) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to destroy encrypted result
|
||||
*/
|
||||
static inline void spi_flash_encrypt_ll_destroy(void)
|
||||
{
|
||||
REG_WRITE(AES_XTS_DESTROY_REG, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is qualified to encrypt the buffer
|
||||
*
|
||||
* @param address the address of written flash partition.
|
||||
* @param length Buffer size.
|
||||
*/
|
||||
static inline bool spi_flash_encrypt_ll_check(uint32_t address, uint32_t length)
|
||||
{
|
||||
return ((address % length) == 0) ? true : false;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -995,7 +995,7 @@ static inline void spi_ll_set_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask)
|
||||
|
||||
static inline void spi_ll_clear_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask)
|
||||
{
|
||||
#define CLR_INTR(intr_bit, _, __, clr_op) if (intr_mask & (intr_bit)) hw->clr_op;
|
||||
#define CLR_INTR(intr_bit, _, __, clr_reg) if (intr_mask & (intr_bit)) hw->clr_reg;
|
||||
FOR_EACH_ITEM(CLR_INTR, INTR_LIST);
|
||||
#undef CLR_INTR
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -13,124 +13,158 @@
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "soc/systimer_struct.h"
|
||||
|
||||
#define SYSTIMER_LL_COUNTER_CLOCK (0) // Counter used for "wallclock" time
|
||||
#define SYSTIMER_LL_ALARM_CLOCK (2) // Alarm used for "wallclock" time
|
||||
|
||||
#define SYSTIMER_LL_TICKS_PER_US (80) // 80 systimer ticks == 1us
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/systimer_reg.h"
|
||||
|
||||
// All these functions get invoked either from ISR or HAL that linked to IRAM.
|
||||
// Always inline these functions even no gcc optimization is applied.
|
||||
|
||||
/*******************counter*************************/
|
||||
/******************* Clock *************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_clock(void)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_clock(systimer_dev_t *dev, bool en)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_CONF_REG, SYSTIMER_CLK_EN);
|
||||
dev->conf.clk_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_apply_counter_value(void)
|
||||
/******************* Counter *************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_counter(systimer_dev_t *dev, uint32_t counter_id, bool en)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_LOAD_REG, SYSTIMER_TIMER_LOAD);
|
||||
// ESP32-S2 only has one counter in systimer group
|
||||
(void)dev;
|
||||
(void)counter_id;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_load_counter_value(uint64_t value)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_counter_can_stall_by_cpu(systimer_dev_t *dev, uint32_t counter_id, uint32_t cpu_id, bool can)
|
||||
{
|
||||
REG_WRITE(SYSTIMER_LOAD_LO_REG, value & 0xFFFFFFFF);
|
||||
REG_WRITE(SYSTIMER_LOAD_HI_REG, (value & 0xFFFFFFFF00000000) >> 32);
|
||||
(void)dev;
|
||||
(void)counter_id;
|
||||
(void)cpu_id;
|
||||
(void)can;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_step_for_pll(uint32_t step)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_counter_snapshot(systimer_dev_t *dev, uint32_t counter_id)
|
||||
{
|
||||
REG_SET_FIELD(SYSTIMER_STEP_REG, SYSTIMER_TIMER_PLL_STEP, step);
|
||||
(void)counter_id;
|
||||
dev->update.timer_update = 1;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_step_for_xtal(uint32_t step)
|
||||
__attribute__((always_inline)) static inline bool systimer_ll_is_counter_value_valid(systimer_dev_t *dev, uint32_t counter_id)
|
||||
{
|
||||
REG_SET_FIELD(SYSTIMER_STEP_REG, SYSTIMER_TIMER_XTAL_STEP, step);
|
||||
(void)counter_id;
|
||||
return dev->update.timer_value_valid;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_counter_snapshot(void)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_counter_value(systimer_dev_t *dev, uint32_t counter_id, uint64_t value)
|
||||
{
|
||||
REG_WRITE(SYSTIMER_UPDATE_REG, SYSTIMER_TIMER_UPDATE);
|
||||
(void)counter_id;
|
||||
dev->load_hi.timer_load_hi = value >> 32;
|
||||
dev->load_lo.timer_load_lo = value;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline bool systimer_ll_is_counter_value_valid(void)
|
||||
__attribute__((always_inline)) static inline uint32_t systimer_ll_get_counter_value_low(systimer_dev_t *dev, uint32_t counter_id)
|
||||
{
|
||||
return REG_GET_BIT(SYSTIMER_UPDATE_REG, SYSTIMER_TIMER_VALUE_VALID);
|
||||
return dev->value_lo.timer_value_lo;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t systimer_ll_get_counter_value_low(void)
|
||||
__attribute__((always_inline)) static inline uint32_t systimer_ll_get_counter_value_high(systimer_dev_t *dev, uint32_t counter_id)
|
||||
{
|
||||
return REG_READ(SYSTIMER_VALUE_LO_REG);
|
||||
return dev->value_hi.timer_value_hi;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t systimer_ll_get_counter_value_high(void)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_apply_counter_value(systimer_dev_t *dev, uint32_t counter_id)
|
||||
{
|
||||
return REG_READ(SYSTIMER_VALUE_HI_REG);
|
||||
dev->load.timer_load = 1;
|
||||
}
|
||||
|
||||
/*******************alarm*************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_alarm_value(uint32_t alarm_id, uint64_t value)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_step_for_pll(systimer_dev_t *dev, uint32_t step)
|
||||
{
|
||||
REG_WRITE(SYSTIMER_TARGET0_LO_REG + alarm_id * 8, value & 0xFFFFFFFF);
|
||||
REG_WRITE(SYSTIMER_TARGET0_HI_REG + alarm_id * 8, (value & 0xFFFFFFFF00000000) >> 32);
|
||||
dev->step.timer_pll_step = step;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint64_t systimer_ll_get_alarm_value(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_step_for_xtal(systimer_dev_t *dev, uint32_t step)
|
||||
{
|
||||
return (uint64_t)REG_READ(SYSTIMER_TARGET0_HI_REG + alarm_id * 8) << 32 | REG_READ(SYSTIMER_TARGET0_LO_REG + alarm_id * 8);
|
||||
dev->step.timer_xtal_step = step;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm(uint32_t alarm_id)
|
||||
/******************* Alarm *************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_alarm_target(systimer_dev_t *dev, uint32_t alarm_id, uint64_t value)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_TARGET0_CONF_REG + alarm_id * 4, BIT(31));
|
||||
dev->target_val[alarm_id].hi.timer_target_hi = value >> 32;
|
||||
dev->target_val[alarm_id].lo.timer_target_lo = value;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_disable_alarm(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline uint64_t systimer_ll_get_alarm_target(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
REG_CLR_BIT(SYSTIMER_TARGET0_CONF_REG + alarm_id * 4, BIT(31));
|
||||
return ((uint64_t)(dev->target_val[alarm_id].hi.timer_target_hi) << 32) | dev->target_val[alarm_id].lo.timer_target_lo;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_oneshot(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_connect_alarm_counter(systimer_dev_t *dev, uint32_t alarm_id, uint32_t counter_id)
|
||||
{
|
||||
REG_CLR_BIT(SYSTIMER_TARGET0_CONF_REG + alarm_id * 4, BIT(30));
|
||||
// On esp32-s2, counter int the systimer is fixed connectred to other three alarm comparators
|
||||
(void)dev;
|
||||
(void)alarm_id;
|
||||
(void)counter_id;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_period(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_oneshot(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_TARGET0_CONF_REG + alarm_id * 4, BIT(30));
|
||||
dev->target_conf[alarm_id].target_period_mode = 0;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_alarm_period(uint32_t alarm_id, uint32_t period)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_period(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
REG_SET_FIELD(SYSTIMER_TARGET0_CONF_REG + alarm_id * 4, SYSTIMER_TARGET0_PERIOD, period);
|
||||
dev->target_conf[alarm_id].target_period_mode = 1;
|
||||
}
|
||||
|
||||
/*******************interrupt*************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_int(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_alarm_period(systimer_dev_t *dev, uint32_t alarm_id, uint32_t period)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_INT_ENA_REG, 1 << alarm_id);
|
||||
assert(period < (1 << 30));
|
||||
dev->target_conf[alarm_id].target_period = period;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_disable_alarm_int(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_apply_alarm_value(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
REG_CLR_BIT(SYSTIMER_INT_ENA_REG, 1 << alarm_id);
|
||||
(void)dev;
|
||||
(void)alarm_id;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline bool systimer_ll_is_alarm_int_fired(uint32_t alarm_id)
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm(systimer_dev_t *dev, uint32_t alarm_id, bool en)
|
||||
{
|
||||
return REG_GET_BIT(SYSTIMER_INT_RAW_REG, 1 << alarm_id);
|
||||
dev->target_conf[alarm_id].target_work_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_clear_alarm_int(uint32_t alarm_id)
|
||||
/******************* Interrupt *************************/
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_enable_alarm_int(systimer_dev_t *dev, uint32_t alarm_id, bool en)
|
||||
{
|
||||
REG_SET_BIT(SYSTIMER_INT_CLR_REG, 1 << alarm_id);
|
||||
if (en) {
|
||||
dev->int_ena.val |= 1 << alarm_id;
|
||||
} else {
|
||||
dev->int_ena.val &= ~(1 << alarm_id);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline bool systimer_ll_is_alarm_int_fired(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
return dev->int_raw.val & (1 << alarm_id);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_clear_alarm_int(systimer_dev_t *dev, uint32_t alarm_id)
|
||||
{
|
||||
dev->int_clr.val |= 1 << alarm_id;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG
|
||||
controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and
|
||||
including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them
|
||||
to the "usb.h" header instead.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USB speeds supported by the DWC OTG controller
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PRIV_SPEED_FULL,
|
||||
USB_PRIV_SPEED_LOW,
|
||||
} usb_priv_speed_t;
|
||||
|
||||
/**
|
||||
* @brief USB transfer types supported by the DWC OTG controller
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PRIV_XFER_TYPE_CTRL,
|
||||
USB_PRIV_XFER_TYPE_ISOCHRONOUS,
|
||||
USB_PRIV_XFER_TYPE_BULK,
|
||||
USB_PRIV_XFER_TYPE_INTR,
|
||||
} usb_priv_xfer_type_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -28,7 +28,7 @@ NOTE: Thread safety is the responsibility fo the HAL user. All USB Host HAL
|
||||
#include "soc/usbh_struct.h"
|
||||
#include "soc/usb_wrap_struct.h"
|
||||
#include "hal/usbh_ll.h"
|
||||
#include "hal/usb_types.h"
|
||||
#include "hal/usb_types_private.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
------------------------------- Macros and Types -------------------------------
|
||||
@ -121,7 +121,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
usb_xfer_type_t type: 2; /**< The type of endpoint */
|
||||
usb_priv_xfer_type_t type: 2; /**< The type of endpoint */
|
||||
uint32_t bEndpointAddress: 8; /**< Endpoint address (containing endpoint number and direction) */
|
||||
uint32_t mps: 11; /**< Maximum Packet Size */
|
||||
uint32_t dev_addr: 8; /**< Device Address */
|
||||
@ -413,9 +413,9 @@ static inline bool usbh_hal_port_check_if_connected(usbh_hal_context_t *hal)
|
||||
* connected to the host port
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @return usb_speed_t Speed of the connected device
|
||||
* @return usb_priv_speed_t Speed of the connected device (FS or LS only on the esp32-s2)
|
||||
*/
|
||||
static inline usb_speed_t usbh_hal_port_get_conn_speed(usbh_hal_context_t *hal)
|
||||
static inline usb_priv_speed_t usbh_hal_port_get_conn_speed(usbh_hal_context_t *hal)
|
||||
{
|
||||
return usbh_ll_hprt_get_speed(hal->dev);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
#include "soc/usbh_struct.h"
|
||||
#include "soc/usb_wrap_struct.h"
|
||||
#include "hal/usb_types.h"
|
||||
#include "hal/usb_types_private.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
------------------------------- Global Registers -------------------------------
|
||||
@ -419,7 +419,7 @@ static inline void usbh_ll_hcfg_set_fsls_pclk_sel(usbh_dev_t *hw)
|
||||
*
|
||||
* @param hw
|
||||
*/
|
||||
static inline void usbh_ll_hcfg_set_defaults(usbh_dev_t *hw, usb_speed_t speed)
|
||||
static inline void usbh_ll_hcfg_set_defaults(usbh_dev_t *hw, usb_priv_speed_t speed)
|
||||
{
|
||||
hw->hcfg_reg.descdma = 1; //Enable scatt/gatt
|
||||
hw->hcfg_reg.fslssupp = 1; //FS/LS supp only
|
||||
@ -428,13 +428,13 @@ static inline void usbh_ll_hcfg_set_defaults(usbh_dev_t *hw, usb_speed_t speed)
|
||||
Note: It seems like our PHY has an implicit 8 divider applied when in LS mode,
|
||||
so the values of FSLSPclkSel and FrInt have to be adjusted accordingly.
|
||||
*/
|
||||
hw->hcfg_reg.fslspclksel = (speed == USB_SPEED_FULL) ? 1 : 2;
|
||||
hw->hcfg_reg.fslspclksel = (speed == USB_PRIV_SPEED_FULL) ? 1 : 2; //esp32-s2 only supports FS or LS
|
||||
hw->hcfg_reg.perschedena = 0; //Disable perio sched
|
||||
}
|
||||
|
||||
// ----------------------------- HFIR Register ---------------------------------
|
||||
|
||||
static inline void usbh_ll_hfir_set_defaults(usbh_dev_t *hw, usb_speed_t speed)
|
||||
static inline void usbh_ll_hfir_set_defaults(usbh_dev_t *hw, usb_priv_speed_t speed)
|
||||
{
|
||||
usb_hfir_reg_t hfir;
|
||||
hfir.val = hw->hfir_reg.val;
|
||||
@ -444,7 +444,7 @@ static inline void usbh_ll_hfir_set_defaults(usbh_dev_t *hw, usb_speed_t speed)
|
||||
Note: It seems like our PHY has an implicit 8 divider applied when in LS mode,
|
||||
so the values of FSLSPclkSel and FrInt have to be adjusted accordingly.
|
||||
*/
|
||||
hfir.frint = (speed == USB_SPEED_FULL) ? 48000 : 6000;
|
||||
hfir.frint = (speed == USB_PRIV_SPEED_FULL) ? 48000 : 6000; //esp32-s2 only supports FS or LS
|
||||
hw->hfir_reg.val = hfir.val;
|
||||
}
|
||||
|
||||
@ -510,14 +510,19 @@ static inline uint32_t usbh_ll_get_frame_list_base_addr(usbh_dev_t *hw)
|
||||
|
||||
// ----------------------------- HPRT Register ---------------------------------
|
||||
|
||||
static inline usb_speed_t usbh_ll_hprt_get_speed(usbh_dev_t *hw)
|
||||
static inline usb_priv_speed_t usbh_ll_hprt_get_speed(usbh_dev_t *hw)
|
||||
{
|
||||
int prtspd = hw->hprt_reg.prtspd;
|
||||
if (prtspd == 1) {
|
||||
return USB_SPEED_FULL;
|
||||
} else {
|
||||
return USB_SPEED_LOW;
|
||||
usb_priv_speed_t speed;
|
||||
//esp32-s2 only supports FS or LS
|
||||
switch (hw->hprt_reg.prtspd) {
|
||||
case 1:
|
||||
speed = USB_PRIV_SPEED_FULL;
|
||||
break;
|
||||
default:
|
||||
speed = USB_PRIV_SPEED_LOW;
|
||||
break;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
static inline uint32_t usbh_ll_hprt_get_test_ctl(usbh_dev_t *hw)
|
||||
@ -674,24 +679,24 @@ static inline void usbh_ll_chan_set_dev_addr(volatile usb_host_chan_regs_t *chan
|
||||
chan->hcchar_reg.devaddr = addr;
|
||||
}
|
||||
|
||||
static inline void usbh_ll_chan_set_ep_type(volatile usb_host_chan_regs_t *chan, usb_xfer_type_t type)
|
||||
static inline void usbh_ll_chan_set_ep_type(volatile usb_host_chan_regs_t *chan, usb_priv_xfer_type_t type)
|
||||
{
|
||||
uint32_t ep_type;
|
||||
switch (type) {
|
||||
case USB_XFER_TYPE_CTRL:
|
||||
chan->hcchar_reg.eptype = 0x0;
|
||||
case USB_PRIV_XFER_TYPE_CTRL:
|
||||
ep_type = 0;
|
||||
break;
|
||||
case USB_XFER_TYPE_ISOCHRONOUS:
|
||||
chan->hcchar_reg.eptype = 0x1;
|
||||
case USB_PRIV_XFER_TYPE_ISOCHRONOUS:
|
||||
ep_type = 1;
|
||||
break;
|
||||
case USB_XFER_TYPE_BULK:
|
||||
chan->hcchar_reg.eptype = 0x2;
|
||||
case USB_PRIV_XFER_TYPE_BULK:
|
||||
ep_type = 2;
|
||||
break;
|
||||
case USB_XFER_TYPE_INTR:
|
||||
chan->hcchar_reg.eptype = 0x3;
|
||||
default: //USB_PRIV_XFER_TYPE_INTR
|
||||
ep_type = 3;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
chan->hcchar_reg.eptype = ep_type;
|
||||
}
|
||||
|
||||
//Indicates whether channel is commuunicating with a LS device connected via a FS hub. Setting this bit to 1 will cause
|
||||
@ -716,9 +721,9 @@ static inline void usbh_ll_chan_set_mps(volatile usb_host_chan_regs_t *chan, uin
|
||||
chan->hcchar_reg.mps = mps;
|
||||
}
|
||||
|
||||
static inline void usbh_ll_chan_hcchar_init(volatile usb_host_chan_regs_t *chan, int dev_addr, int ep_num, int mps, usb_xfer_type_t type, bool is_in, bool is_ls)
|
||||
static inline void usbh_ll_chan_hcchar_init(volatile usb_host_chan_regs_t *chan, int dev_addr, int ep_num, int mps, usb_priv_xfer_type_t type, bool is_in, bool is_ls)
|
||||
{
|
||||
//Sets all persistent fields of the channel over its lifetime
|
||||
//Sets all persistent fields of the channel over its lifetimez
|
||||
usbh_ll_chan_set_dev_addr(chan, dev_addr);
|
||||
usbh_ll_chan_set_ep_type(chan, type);
|
||||
usbh_ll_chan_set_lspddev(chan, is_ls);
|
||||
|
@ -60,11 +60,6 @@ void ds_hal_start(void);
|
||||
*/
|
||||
void ds_hal_finish(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether the key input (HMAC on ESP32-C3) is correct.
|
||||
*/
|
||||
ds_key_check_t ds_hal_check_decryption_key(void);
|
||||
|
||||
/**
|
||||
* @brief Write the initialization vector.
|
||||
*/
|
||||
|
@ -76,6 +76,9 @@ typedef enum {
|
||||
#define GPIO_SEL_44 ((uint64_t)(((uint64_t)1)<<44)) /*!< Pin 44 selected */
|
||||
#define GPIO_SEL_45 ((uint64_t)(((uint64_t)1)<<45)) /*!< Pin 45 selected */
|
||||
#define GPIO_SEL_46 ((uint64_t)(((uint64_t)1)<<46)) /*!< Pin 46 selected */
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#define GPIO_SEL_47 ((uint64_t)(((uint64_t)1)<<47)) /*!< Pin 47 selected */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GPIO_PIN_REG_0 IO_MUX_GPIO0_REG
|
||||
@ -125,6 +128,7 @@ typedef enum {
|
||||
#define GPIO_PIN_REG_44 IO_MUX_GPIO44_REG
|
||||
#define GPIO_PIN_REG_45 IO_MUX_GPIO45_REG
|
||||
#define GPIO_PIN_REG_46 IO_MUX_GPIO46_REG
|
||||
#define GPIO_PIN_REG_47 IO_MUX_GPIO47_REG
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
typedef enum {
|
||||
|
@ -135,6 +135,16 @@ static inline void interrupt_controller_hal_disable_interrupts(uint32_t mask)
|
||||
intr_cntrl_ll_disable_interrupts(mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the current interrupt mask.
|
||||
*
|
||||
* @return The bitmask of current interrupts
|
||||
*/
|
||||
static inline uint32_t interrupt_controller_hal_read_interrupt_mask(void)
|
||||
{
|
||||
return intr_cntrl_ll_read_interrupt_mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief checks if given interrupt number has a valid handler
|
||||
*
|
||||
@ -171,27 +181,6 @@ static inline void * interrupt_controller_hal_get_int_handler_arg(uint8_t intr)
|
||||
return intr_cntrl_ll_get_int_handler_arg(intr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables interrupts that are not located in iram
|
||||
*
|
||||
* @param newmask mask of interrupts needs to be disabled
|
||||
* @return oldmask where to store old interrupts state
|
||||
*/
|
||||
static inline uint32_t interrupt_controller_hal_disable_int_mask(uint32_t newmask)
|
||||
{
|
||||
return intr_cntrl_ll_disable_int_mask(newmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enables interrupts that are not located in iram
|
||||
*
|
||||
* @param newmask mask of interrupts needs to be disabled
|
||||
*/
|
||||
static inline void interrupt_controller_hal_enable_int_mask(uint32_t newmask)
|
||||
{
|
||||
intr_cntrl_ll_enable_int_mask(newmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Acknowledge an edge-trigger interrupt by clearing its pending flag
|
||||
*
|
||||
|
@ -134,6 +134,10 @@ typedef struct {
|
||||
ledc_timer_t timer_sel; /*!< Select the timer source of channel (0 - 3) */
|
||||
uint32_t duty; /*!< LEDC channel duty, the range of duty setting is [0, (2**duty_resolution)] */
|
||||
int hpoint; /*!< LEDC channel hpoint value, the max value is 0xfffff */
|
||||
struct {
|
||||
unsigned int output_invert: 1;/*!< Enable (1) or disable (0) gpio output invert */
|
||||
} flags; /*!< LEDC flags */
|
||||
|
||||
} ledc_channel_config_t;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,62 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The HAL is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SPI Flash Encryption
|
||||
|
||||
#include "hal/spi_flash_encrypted_ll.h"
|
||||
|
||||
/**
|
||||
* @brief Enable the flash encryption
|
||||
*/
|
||||
void spi_flash_encryption_hal_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable the flash encryption
|
||||
*/
|
||||
void spi_flash_encryption_hal_disable(void);
|
||||
|
||||
/**
|
||||
* Prepare flash encryption before operation.
|
||||
*
|
||||
* @param address The destination address in flash for the write operation.
|
||||
* @param buffer Data for programming
|
||||
* @param size Size to program.
|
||||
*
|
||||
* @note address and buffer must be 8-word aligned.
|
||||
*/
|
||||
void spi_flash_encryption_hal_prepare(uint32_t address, const uint32_t* buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief flash data encryption operation is done.
|
||||
*/
|
||||
void spi_flash_encryption_hal_done(void);
|
||||
|
||||
/**
|
||||
* Destroy encrypted result
|
||||
*/
|
||||
void spi_flash_encryption_hal_destroy(void);
|
||||
|
||||
/**
|
||||
* Check if is qualified to encrypt the buffer
|
||||
*
|
||||
* @param address the address of written flash partition.
|
||||
* @param length Buffer size.
|
||||
*/
|
||||
bool spi_flash_encryption_hal_check(uint32_t address, uint32_t length);
|
@ -86,6 +86,44 @@ typedef struct {
|
||||
};
|
||||
} spi_flash_sus_cmd_conf;
|
||||
|
||||
/// Structure for flash encryption operations.
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Enable the flash encryption
|
||||
*/
|
||||
void (*flash_encryption_enable)(void);
|
||||
/**
|
||||
* @brief Disable the flash encryption
|
||||
*/
|
||||
void (*flash_encryption_disable)(void);
|
||||
/**
|
||||
* Prepare flash encryption before operation.
|
||||
*
|
||||
* @param address The destination address in flash for the write operation.
|
||||
* @param buffer Data for programming
|
||||
* @param size Size to program.
|
||||
*
|
||||
* @note address and buffer must be 8-word aligned.
|
||||
*/
|
||||
void (*flash_encryption_data_prepare)(uint32_t address, const uint32_t* buffer, uint32_t size);
|
||||
/**
|
||||
* @brief flash data encryption operation is done.
|
||||
*/
|
||||
void (*flash_encryption_done)(void);
|
||||
/**
|
||||
* Destroy encrypted result
|
||||
*/
|
||||
void (*flash_encryption_destroy)(void);
|
||||
/**
|
||||
* Check if is qualified to encrypt the buffer
|
||||
*
|
||||
* @param address the address of written flash partition.
|
||||
* @param length Buffer size.
|
||||
*/
|
||||
bool (*flash_encryption_check)(uint32_t address, uint32_t length);
|
||||
} spi_flash_encryption_t;
|
||||
|
||||
///Slowest io mode supported by ESP32, currently SlowRd
|
||||
#define SPI_FLASH_READ_MODE_MIN SPI_FLASH_SLOWRD
|
||||
|
||||
|
@ -31,13 +31,17 @@ typedef enum {
|
||||
|
||||
/// SPI Events
|
||||
typedef enum {
|
||||
SPI_EV_BUF_TX = BIT(0), ///< The buffer has sent data to master, Slave HD only
|
||||
SPI_EV_BUF_RX = BIT(1), ///< The buffer has received data from master, Slave HD only
|
||||
SPI_EV_SEND = BIT(2), ///< Slave has loaded some data to DMA, and master has received certain number of the data, the number is determined by master. Slave HD only
|
||||
SPI_EV_RECV = BIT(3), ///< Slave has received certain number of data from master, the number is determined by master. Slave HD only.
|
||||
SPI_EV_CMD9 = BIT(4), ///< Received CMD9 from master, Slave HD only
|
||||
SPI_EV_CMDA = BIT(5), ///< Received CMDA from master, Slave HD only
|
||||
SPI_EV_TRANS = BIT(6), ///< A transaction has done
|
||||
/* Slave HD Only */
|
||||
SPI_EV_BUF_TX = BIT(0), ///< The buffer has sent data to master.
|
||||
SPI_EV_BUF_RX = BIT(1), ///< The buffer has received data from master.
|
||||
SPI_EV_SEND_DMA_READY = BIT(2), ///< Slave has loaded its TX data buffer to the hardware (DMA).
|
||||
SPI_EV_SEND = BIT(3), ///< Master has received certain number of the data, the number is determined by Master.
|
||||
SPI_EV_RECV_DMA_READY = BIT(4), ///< Slave has loaded its RX data buffer to the hardware (DMA).
|
||||
SPI_EV_RECV = BIT(5), ///< Slave has received certain number of data from master, the number is determined by Master.
|
||||
SPI_EV_CMD9 = BIT(6), ///< Received CMD9 from master.
|
||||
SPI_EV_CMDA = BIT(7), ///< Received CMDA from master.
|
||||
/* Common Event */
|
||||
SPI_EV_TRANS = BIT(8), ///< A transaction has done
|
||||
} spi_event_t;
|
||||
FLAG_ATTR(spi_event_t)
|
||||
|
||||
|
@ -14,78 +14,91 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/systimer_struct.h"
|
||||
#include "hal/systimer_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/systimer_types.h"
|
||||
|
||||
/**
|
||||
* @brief enable systimer counter
|
||||
*/
|
||||
void systimer_hal_enable_counter(systimer_counter_id_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current counter value
|
||||
*/
|
||||
uint64_t systimer_hal_get_counter_value(systimer_counter_id_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current time (in microseconds)
|
||||
*/
|
||||
uint64_t systimer_hal_get_time(systimer_counter_id_t counter_id);
|
||||
|
||||
/*
|
||||
* @brief set alarm target value (used in one-shot mode)
|
||||
*/
|
||||
void systimer_hal_set_alarm_target(systimer_alarm_id_t alarm_id, uint64_t target);
|
||||
|
||||
/**
|
||||
* @brief set alarm period value (used in period mode)
|
||||
*/
|
||||
void systimer_hal_set_alarm_period(systimer_alarm_id_t alarm_id, uint32_t period);
|
||||
|
||||
/**
|
||||
* @brief get alarm time
|
||||
*/
|
||||
uint64_t systimer_hal_get_alarm_value(systimer_alarm_id_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief enable alarm interrupt
|
||||
*/
|
||||
void systimer_hal_enable_alarm_int(systimer_alarm_id_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief select alarm mode
|
||||
*/
|
||||
void systimer_hal_select_alarm_mode(systimer_alarm_id_t alarm_id, systimer_alarm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief update systimer step when apb clock gets changed
|
||||
*/
|
||||
void systimer_hal_on_apb_freq_update(uint32_t apb_ticks_per_us);
|
||||
|
||||
/**
|
||||
* @brief move systimer counter value forward or backward
|
||||
*/
|
||||
void systimer_hal_counter_value_advance(systimer_counter_id_t counter_id, int64_t time_us);
|
||||
typedef struct {
|
||||
systimer_dev_t *dev;
|
||||
} systimer_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief initialize systimer in HAL layer
|
||||
*/
|
||||
void systimer_hal_init(void);
|
||||
void systimer_hal_init(systimer_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief enable systimer counter
|
||||
*/
|
||||
void systimer_hal_enable_counter(systimer_hal_context_t *hal, uint32_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current counter value
|
||||
*/
|
||||
uint64_t systimer_hal_get_counter_value(systimer_hal_context_t *hal, uint32_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current time (in microseconds)
|
||||
*/
|
||||
uint64_t systimer_hal_get_time(systimer_hal_context_t *hal, uint32_t counter_id);
|
||||
|
||||
/*
|
||||
* @brief set alarm target value (used in one-shot mode)
|
||||
*/
|
||||
void systimer_hal_set_alarm_target(systimer_hal_context_t *hal, uint32_t alarm_id, uint64_t target);
|
||||
|
||||
/**
|
||||
* @brief set alarm period value (used in period mode)
|
||||
*/
|
||||
void systimer_hal_set_alarm_period(systimer_hal_context_t *hal, uint32_t alarm_id, uint32_t period);
|
||||
|
||||
/**
|
||||
* @brief get alarm time
|
||||
*/
|
||||
uint64_t systimer_hal_get_alarm_value(systimer_hal_context_t *hal, uint32_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief enable alarm interrupt
|
||||
*/
|
||||
void systimer_hal_enable_alarm_int(systimer_hal_context_t *hal, uint32_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief select alarm mode
|
||||
*/
|
||||
void systimer_hal_select_alarm_mode(systimer_hal_context_t *hal, uint32_t alarm_id, systimer_alarm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief update systimer step when apb clock gets changed
|
||||
*/
|
||||
void systimer_hal_on_apb_freq_update(systimer_hal_context_t *hal, uint32_t apb_ticks_per_us);
|
||||
|
||||
/**
|
||||
* @brief move systimer counter value forward or backward
|
||||
*/
|
||||
void systimer_hal_counter_value_advance(systimer_hal_context_t *hal, uint32_t counter_id, int64_t time_us);
|
||||
|
||||
/**
|
||||
* @brief connect alarm unit to selected counter
|
||||
*/
|
||||
void systimer_hal_connect_alarm_counter(systimer_alarm_id_t alarm_id, systimer_counter_id_t counter_id);
|
||||
void systimer_hal_connect_alarm_counter(systimer_hal_context_t *hal, uint32_t alarm_id, uint32_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief set if a counter should be stalled when CPU is halted by the debugger
|
||||
*/
|
||||
void systimer_hal_counter_can_stall_by_cpu(uint32_t counter_id, uint32_t cpu_id, bool can);
|
||||
void systimer_hal_counter_can_stall_by_cpu(systimer_hal_context_t *hal, uint32_t counter_id, uint32_t cpu_id, bool can);
|
||||
|
||||
#if !SOC_SYSTIMER_FIXED_TICKS_US
|
||||
/**
|
||||
* @brief set increase steps for systimer counter on different clock source
|
||||
*/
|
||||
void systimer_hal_set_steps_per_tick(systimer_hal_context_t *hal, int clock_source, uint32_t steps);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
/*
|
||||
* @brief The structure of the counter value in systimer
|
||||
*
|
||||
@ -39,27 +39,6 @@ typedef struct {
|
||||
_Static_assert(sizeof(systimer_counter_value_t) == 8, "systimer_counter_value_t should occupy 8 bytes in memory");
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief systimer counter ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SYSTIMER_COUNTER_0, /*!< systimer counter 0 */
|
||||
#if SOC_SYSTIMER_COUNTER_NUM > 1
|
||||
SYSTIMER_COUNTER_1, /*!< systimer counter 1 */
|
||||
#endif
|
||||
} systimer_counter_id_t;
|
||||
|
||||
/**
|
||||
* @brief systimer alarm ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SYSTIMER_ALARM_0, /*!< systimer alarm 0 */
|
||||
SYSTIMER_ALARM_1, /*!< systimer alarm 1 */
|
||||
SYSTIMER_ALARM_2, /*!< systimer alarm 2 */
|
||||
} systimer_alarm_id_t;
|
||||
|
||||
/**
|
||||
* @brief systimer alarm mode
|
||||
*
|
||||
|
@ -1,452 +0,0 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define USB_CTRL_REQ_ATTR __attribute__((packed))
|
||||
#define USB_DESC_ATTR __attribute__((packed))
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
------------------------------- Common USB Types -------------------------------
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
// ----------------------------- Device Related --------------------------------
|
||||
|
||||
/**
|
||||
* @brief Enumeration of USB PHY type
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PHY_INTERNAL = 0, /**< Use the chip's internal USB PHY */
|
||||
USB_PHY_EXTERNAL, /**< Use an external USB PHY */
|
||||
} usb_phy_t;
|
||||
|
||||
// ------------------------------ Bus Related ----------------------------------
|
||||
|
||||
/**
|
||||
* @brief USB Standard Speeds
|
||||
*/
|
||||
typedef enum {
|
||||
USB_SPEED_LOW = 0, /**< USB Low Speed (1.5 Mbit/s) */
|
||||
USB_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */
|
||||
} usb_speed_t;
|
||||
|
||||
// ---------------------------- Transfer Related -------------------------------
|
||||
|
||||
/**
|
||||
* @brief The type of USB transfer
|
||||
*
|
||||
* @note The enum values need to match the bmAttributes field of an EP descriptor
|
||||
*/
|
||||
typedef enum {
|
||||
USB_XFER_TYPE_CTRL = 0,
|
||||
USB_XFER_TYPE_ISOCHRONOUS,
|
||||
USB_XFER_TYPE_BULK,
|
||||
USB_XFER_TYPE_INTR,
|
||||
} usb_xfer_type_t;
|
||||
|
||||
/**
|
||||
* @brief The status of a particular transfer
|
||||
*/
|
||||
typedef enum {
|
||||
USB_TRANSFER_STATUS_COMPLETED, /**< The transfer was successful (but may be short) */
|
||||
USB_TRANSFER_STATUS_ERROR, /**< The transfer failed because due to excessive errors (e.g. no response or CRC error) */
|
||||
USB_TRANSFER_STATUS_TIMED_OUT, /**< The transfer failed due to to a time out */
|
||||
USB_TRANSFER_STATUS_CANCELLED, /**< The transfer was cancelled */
|
||||
USB_TRANSFER_STATUS_STALL, /**< The transfer was stalled */
|
||||
USB_TRANSFER_STATUS_NO_DEVICE, /**< The transfer failed because the device is no longer valid (e.g., disconencted */
|
||||
USB_TRANSFER_STATUS_OVERFLOW, /**< The transfer as more data was sent than was requested */
|
||||
} usb_transfer_status_t;
|
||||
|
||||
/**
|
||||
* @brief Isochronous packet descriptor
|
||||
*
|
||||
* If the number of bytes in an IRP transfer is larger than the MPS of the
|
||||
* endpoint, the IRP is split over multiple packets (one packet per bInterval
|
||||
* of the endpoint). An array of Isochronous packet descriptos describes how
|
||||
* an IRP should be split over multiple packets.
|
||||
*/
|
||||
typedef struct {
|
||||
int length; /**< Number of bytes to transmit/receive in the packet */
|
||||
int actual_length; /**< Actual number of bytes transmitted/received in the packet */
|
||||
usb_transfer_status_t status; /**< Status of the packet */
|
||||
} usb_iso_packet_desc_t;
|
||||
|
||||
/**
|
||||
* @brief USB IRP (I/O Request Packet). See USB2.0 Spec
|
||||
*
|
||||
* An identifiable request by a software client to move data between itself (on the
|
||||
* host) and an endpoint of a device in an appropriate direction.
|
||||
*
|
||||
* This structure represents the barebones of the request. Different layers of
|
||||
* USB drivers will wrap their own objects around this.
|
||||
*
|
||||
* See 10.5.3.1 os USB2.0 specification
|
||||
* Bulk: Represnts a single bulk transfer which a pipe will transparently split
|
||||
* into multiple MPS transactions (until the last)
|
||||
* Control: Represents a single contorl transfer with the setup packet at the
|
||||
* first 8 bytes of the buffer.
|
||||
* Interrupt: Represnts a single interrupt transaction
|
||||
* Isochronous: Represnts a buffer of a stream of bytes which the pipe will transparently
|
||||
* transfer the stream of bytes one or more service periods
|
||||
*/
|
||||
typedef struct {
|
||||
int num_bytes; /**< Number of bytes in IRP. Control should exclude size of setup. IN should be integer multiple of MPS */
|
||||
int actual_num_bytes; /**< Actual number of bytes transmitted/receives in the IRP */
|
||||
uint8_t *data_buffer; /**< Pointer to data buffer. Must be DMA capable memory */
|
||||
usb_transfer_status_t status; /**< Status of the transfer */
|
||||
int num_iso_packets; /**< Only relevant to isochronous. Number of service periods to transfer data buffer over. Set to 0 for non-iso transfers */
|
||||
usb_iso_packet_desc_t iso_packet_desc[0]; /**< Descriptors for each ISO packet */
|
||||
} usb_irp_t;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
----------------------------------- Chapter 9 ----------------------------------
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
// ------------------------------ Control Request ------------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a USB control transfer setup packet in bytes
|
||||
*/
|
||||
#define USB_CTRL_REQ_SIZE 8
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB control transfer setup packet
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bRequestType;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} USB_CTRL_REQ_ATTR;
|
||||
uint8_t val[USB_CTRL_REQ_SIZE];
|
||||
} usb_ctrl_req_t;
|
||||
_Static_assert(sizeof(usb_ctrl_req_t) == USB_CTRL_REQ_SIZE, "Size of usb_ctrl_req_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the bRequestType field of a setup packet
|
||||
*/
|
||||
#define USB_B_REQUEST_TYPE_DIR_OUT (0X00 << 7)
|
||||
#define USB_B_REQUEST_TYPE_DIR_IN (0x01 << 7)
|
||||
#define USB_B_REQUEST_TYPE_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_B_REQUEST_TYPE_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_B_REQUEST_TYPE_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_B_REQUEST_TYPE_TYPE_RESERVED (0x03 << 5)
|
||||
#define USB_B_REQUEST_TYPE_TYPE_MASK (0x03 << 5)
|
||||
#define USB_B_REQUEST_TYPE_RECIP_DEVICE (0x00 << 0)
|
||||
#define USB_B_REQUEST_TYPE_RECIP_INTERFACE (0x01 << 0)
|
||||
#define USB_B_REQUEST_TYPE_RECIP_ENDPOINT (0x02 << 0)
|
||||
#define USB_B_REQUEST_TYPE_RECIP_OTHER (0x03 << 0)
|
||||
#define USB_B_REQUEST_TYPE_RECIP_MASK (0x1f << 0)
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the bRequest field of a setup packet
|
||||
*/
|
||||
#define USB_B_REQUEST_GET_STATUS 0x00
|
||||
#define USB_B_REQUEST_CLEAR_FEATURE 0x01
|
||||
#define USB_B_REQUEST_SET_FEATURE 0x03
|
||||
#define USB_B_REQUEST_SET_ADDRESS 0x05
|
||||
#define USB_B_REQUEST_GET_DESCRIPTOR 0x06
|
||||
#define USB_B_REQUEST_SET_DESCRIPTOR 0x07
|
||||
#define USB_B_REQUEST_GET_CONFIGURATION 0x08
|
||||
#define USB_B_REQUEST_SET_CONFIGURATION 0x09
|
||||
#define USB_B_REQUEST_GET_INTERFACE 0x0A
|
||||
#define USB_B_REQUEST_SET_INTERFACE 0x0B
|
||||
#define USB_B_REQUEST_SYNCH_FRAME 0x0C
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the wValue field of a setup packet
|
||||
*/
|
||||
#define USB_W_VALUE_DT_DEVICE 0x01
|
||||
#define USB_W_VALUE_DT_CONFIG 0x02
|
||||
#define USB_W_VALUE_DT_STRING 0x03
|
||||
#define USB_W_VALUE_DT_INTERFACE 0x04
|
||||
#define USB_W_VALUE_DT_ENDPOINT 0x05
|
||||
#define USB_W_VALUE_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_W_VALUE_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_W_VALUE_DT_INTERFACE_POWER 0x08
|
||||
|
||||
/**
|
||||
* @brief Initializer for a SET_ADDRESS request
|
||||
*
|
||||
* Sets the address of a connected device
|
||||
*/
|
||||
#define USB_CTRL_REQ_INIT_SET_ADDR(ctrl_req_ptr, addr) ({ \
|
||||
(ctrl_req_ptr)->bRequestType = USB_B_REQUEST_TYPE_DIR_OUT | USB_B_REQUEST_TYPE_TYPE_STANDARD |USB_B_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(ctrl_req_ptr)->bRequest = USB_B_REQUEST_SET_ADDRESS; \
|
||||
(ctrl_req_ptr)->wValue = (addr); \
|
||||
(ctrl_req_ptr)->wIndex = 0; \
|
||||
(ctrl_req_ptr)->wLength = 0; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a request to get a device's device descriptor
|
||||
*/
|
||||
#define USB_CTRL_REQ_INIT_GET_DEVC_DESC(ctrl_req_ptr) ({ \
|
||||
(ctrl_req_ptr)->bRequestType = USB_B_REQUEST_TYPE_DIR_IN | USB_B_REQUEST_TYPE_TYPE_STANDARD | USB_B_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(ctrl_req_ptr)->bRequest = USB_B_REQUEST_GET_DESCRIPTOR; \
|
||||
(ctrl_req_ptr)->wValue = (USB_W_VALUE_DT_DEVICE << 8); \
|
||||
(ctrl_req_ptr)->wIndex = 0; \
|
||||
(ctrl_req_ptr)->wLength = 18; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a request to get a device's current configuration number
|
||||
*/
|
||||
#define USB_CTRL_REQ_INIT_GET_CONFIG(ctrl_req_ptr) ({ \
|
||||
(ctrl_req_ptr)->bRequestType = USB_B_REQUEST_TYPE_DIR_IN | USB_B_REQUEST_TYPE_TYPE_STANDARD | USB_B_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(ctrl_req_ptr)->bRequest = USB_B_REQUEST_GET_CONFIGURATION; \
|
||||
(ctrl_req_ptr)->wValue = 0; \
|
||||
(ctrl_req_ptr)->wIndex = 0; \
|
||||
(ctrl_req_ptr)->wLength = 1; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a request to get one of the device's current configuration descriptor
|
||||
*
|
||||
* - desc_index indicates the configuration's index number
|
||||
* - Number of bytes of the configuration descriptor to get
|
||||
*/
|
||||
#define USB_CTRL_REQ_INIT_GET_CFG_DESC(ctrl_req_ptr, desc_index, desc_len) ({ \
|
||||
(ctrl_req_ptr)->bRequestType = USB_B_REQUEST_TYPE_DIR_IN | USB_B_REQUEST_TYPE_TYPE_STANDARD | USB_B_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(ctrl_req_ptr)->bRequest = USB_B_REQUEST_GET_DESCRIPTOR; \
|
||||
(ctrl_req_ptr)->wValue = (USB_W_VALUE_DT_CONFIG << 8) | ((desc_index) & 0xFF); \
|
||||
(ctrl_req_ptr)->wIndex = 0; \
|
||||
(ctrl_req_ptr)->wLength = (desc_len); \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a request to set a device's current configuration number
|
||||
*/
|
||||
#define USB_CTRL_REQ_INIT_SET_CONFIG(ctrl_req_ptr, config_num) ({ \
|
||||
(ctrl_req_ptr)->bRequestType = USB_B_REQUEST_TYPE_DIR_OUT | USB_B_REQUEST_TYPE_TYPE_STANDARD | USB_B_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(ctrl_req_ptr)->bRequest = USB_B_REQUEST_SET_CONFIGURATION; \
|
||||
(ctrl_req_ptr)->wValue = (config_num); \
|
||||
(ctrl_req_ptr)->wIndex = 0; \
|
||||
(ctrl_req_ptr)->wLength = 0; \
|
||||
})
|
||||
|
||||
// ---------------------------- Device Descriptor ------------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a USB device descriptor in bytes
|
||||
*/
|
||||
#define USB_DESC_DEV_SIZE 18
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB device descriptor
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t bcdUSB;
|
||||
uint8_t bDeviceClass;
|
||||
uint8_t bDeviceSubClass;
|
||||
uint8_t bDeviceProtocol;
|
||||
uint8_t bMaxPacketSize0;
|
||||
uint16_t idVendor;
|
||||
uint16_t idProduct;
|
||||
uint16_t bcdDevice;
|
||||
uint8_t iManufacturer;
|
||||
uint8_t iProduct;
|
||||
uint8_t iSerialNumber;
|
||||
uint8_t bNumConfigurations;
|
||||
} USB_DESC_ATTR;
|
||||
uint8_t val[USB_DESC_DEV_SIZE];
|
||||
} usb_desc_devc_t;
|
||||
_Static_assert(sizeof(usb_desc_devc_t) == USB_DESC_DEV_SIZE, "Size of usb_desc_devc_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Possible base class values of the bDeviceClass field of a USB device descriptor
|
||||
*/
|
||||
#define USB_CLASS_PER_INTERFACE 0x00
|
||||
#define USB_CLASS_AUDIO 0x01
|
||||
#define USB_CLASS_COMM 0x02
|
||||
#define USB_CLASS_HID 0x03
|
||||
#define USB_CLASS_PHYSICAL 0x05
|
||||
#define USB_CLASS_STILL_IMAGE 0x06
|
||||
#define USB_CLASS_PRINTER 0x07
|
||||
#define USB_CLASS_MASS_STORAGE 0x08
|
||||
#define USB_CLASS_HUB 0x09
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
#define USB_CLASS_CSCID 0x0b
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d
|
||||
#define USB_CLASS_VIDEO 0x0e
|
||||
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
||||
#define USB_CLASS_PERSONAL_HEALTHCARE 0x0f
|
||||
#define USB_CLASS_AUDIO_VIDEO 0x10
|
||||
#define USB_CLASS_BILLBOARD 0x11
|
||||
#define USB_CLASS_USB_TYPE_C_BRIDGE 0x12
|
||||
#define USB_CLASS_MISC 0xef
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/**
|
||||
* @brief Vendor specific subclass code
|
||||
*/
|
||||
#define USB_SUBCLASS_VENDOR_SPEC 0xff
|
||||
|
||||
// ----------------------- Configuration Descriptor ----------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a short USB configuration descriptor in bytes
|
||||
*
|
||||
* @note The size of a full USB configuration includes all the interface and endpoint
|
||||
* descriptors of that configuration.
|
||||
*/
|
||||
#define USB_DESC_CFG_SIZE 9
|
||||
|
||||
/**
|
||||
* @brief Structure representing a short USB configuration descriptor
|
||||
*
|
||||
* @note The full USB configuration includes all the interface and endpoint
|
||||
* descriptors of that configuration.
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumInterfaces;
|
||||
uint8_t bConfigurationValue;
|
||||
uint8_t iConfiguration;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bMaxPower;
|
||||
} USB_DESC_ATTR;
|
||||
uint8_t val[USB_DESC_CFG_SIZE];
|
||||
} usb_desc_cfg_t;
|
||||
_Static_assert(sizeof(usb_desc_cfg_t) == USB_DESC_CFG_SIZE, "Size of usb_desc_cfg_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the bmAttributes field of a configuration descriptor
|
||||
*/
|
||||
#define USB_BM_ATTRIBUTES_ONE (1 << 7) //Must be set
|
||||
#define USB_BM_ATTRIBUTES_SELFPOWER (1 << 6) //Self powered
|
||||
#define USB_BM_ATTRIBUTES_WAKEUP (1 << 5) //Can wakeup
|
||||
#define USB_BM_ATTRIBUTES_BATTERY (1 << 4) //Battery powered
|
||||
|
||||
// ------------------------- Interface Descriptor ------------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a USB interface descriptor in bytes
|
||||
*/
|
||||
#define USB_DESC_INTF_SIZE 9
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB interface descriptor
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bInterfaceNumber;
|
||||
uint8_t bAlternateSetting;
|
||||
uint8_t bNumEndpoints;
|
||||
uint8_t bInterfaceClass;
|
||||
uint8_t bInterfaceSubClass;
|
||||
uint8_t bInterfaceProtocol;
|
||||
uint8_t iInterface;
|
||||
} USB_DESC_ATTR;
|
||||
uint8_t val[USB_DESC_INTF_SIZE];
|
||||
} usb_desc_intf_t;
|
||||
_Static_assert(sizeof(usb_desc_intf_t) == USB_DESC_INTF_SIZE, "Size of usb_desc_intf_t incorrect");
|
||||
|
||||
// ------------------------- Endpoint Descriptor -------------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a USB endpoint descriptor in bytes
|
||||
*/
|
||||
#define USB_DESC_EP_SIZE 7
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB endp;oint descriptor
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
} USB_DESC_ATTR;
|
||||
uint8_t val[USB_DESC_EP_SIZE];
|
||||
} usb_desc_ep_t;
|
||||
_Static_assert(sizeof(usb_desc_ep_t) == USB_DESC_EP_SIZE, "Size of usb_desc_ep_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the bEndpointAddress field of an endpoint descriptor
|
||||
*/
|
||||
#define USB_B_ENDPOINT_ADDRESS_EP_NUM_MASK 0x0f
|
||||
#define USB_B_ENDPOINT_ADDRESS_EP_DIR_MASK 0x80
|
||||
|
||||
/**
|
||||
* @brief Bit masks pertaining to the bmAttributes field of an endpoint descriptor
|
||||
*/
|
||||
#define USB_BM_ATTRIBUTES_XFERTYPE_MASK 0x03
|
||||
#define USB_BM_ATTRIBUTES_XFER_CONTROL (0 << 0)
|
||||
#define USB_BM_ATTRIBUTES_XFER_ISOC (1 << 0)
|
||||
#define USB_BM_ATTRIBUTES_XFER_BULK (2 << 0)
|
||||
#define USB_BM_ATTRIBUTES_XFER_INT (3 << 0)
|
||||
#define USB_BM_ATTRIBUTES_SYNCTYPE_MASK 0x0C /* in bmAttributes */
|
||||
#define USB_BM_ATTRIBUTES_SYNC_NONE (0 << 2)
|
||||
#define USB_BM_ATTRIBUTES_SYNC_ASYNC (1 << 2)
|
||||
#define USB_BM_ATTRIBUTES_SYNC_ADAPTIVE (2 << 2)
|
||||
#define USB_BM_ATTRIBUTES_SYNC_SYNC (3 << 2)
|
||||
#define USB_BM_ATTRIBUTES_USAGETYPE_MASK 0x30
|
||||
#define USB_BM_ATTRIBUTES_USAGE_DATA (0 << 4)
|
||||
#define USB_BM_ATTRIBUTES_USAGE_FEEDBACK (1 << 4)
|
||||
#define USB_BM_ATTRIBUTES_USAGE_IMPLICIT_FB (2 << 4)
|
||||
|
||||
/**
|
||||
* @brief Macro helpers to get information about an endpoint from its descriptor
|
||||
*/
|
||||
#define USB_DESC_EP_GET_XFERTYPE(desc_ptr) ((usb_xfer_type_t) ((desc_ptr)->bmAttributes & USB_BM_ATTRIBUTES_XFERTYPE_MASK))
|
||||
#define USB_DESC_EP_GET_EP_NUM(desc_ptr) ((desc_ptr)->bEndpointAddress & USB_B_ENDPOINT_ADDRESS_EP_NUM_MASK)
|
||||
#define USB_DESC_EP_GET_EP_DIR(desc_ptr) (((desc_ptr)->bEndpointAddress & USB_B_ENDPOINT_ADDRESS_EP_DIR_MASK) ? 1 : 0)
|
||||
#define USB_DESC_EP_GET_MPS(desc_ptr) ((desc_ptr)->wMaxPacketSize & 0x7FF)
|
||||
|
||||
|
||||
// --------------------------- String Descriptor -------------------------------
|
||||
|
||||
/**
|
||||
* @brief Size of a short USB string descriptor in bytes
|
||||
*/
|
||||
#define USB_DESC_STR_SIZE 4
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB string descriptor
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wData[1]; /* UTF-16LE encoded */
|
||||
} USB_DESC_ATTR;
|
||||
uint8_t val[USB_DESC_STR_SIZE];
|
||||
} usb_desc_str_t;
|
||||
_Static_assert(sizeof(usb_desc_str_t) == USB_DESC_STR_SIZE, "Size of usb_desc_str_t incorrect");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_LOG_H__
|
||||
#define __ESP_LOG_H__
|
||||
@ -48,13 +40,22 @@ typedef enum {
|
||||
|
||||
typedef int (*vprintf_like_t)(const char *, va_list);
|
||||
|
||||
/**
|
||||
* @brief Default log level
|
||||
*
|
||||
* This is used by the definition of ESP_EARLY_LOGx macros. It is not
|
||||
* recommended to set this directly, call esp_log_level_set("*", level)
|
||||
* instead.
|
||||
*/
|
||||
extern esp_log_level_t esp_log_default_level;
|
||||
|
||||
/**
|
||||
* @brief Set log level for given tag
|
||||
*
|
||||
* If logging for given component has already been enabled, changes previous setting.
|
||||
*
|
||||
* Note that this function can not raise log level above the level set using
|
||||
* CONFIG_LOG_DEFAULT_LEVEL setting in menuconfig.
|
||||
* CONFIG_LOG_MAXIMUM_LEVEL setting in menuconfig.
|
||||
*
|
||||
* To raise log level above the default one for a given file, define
|
||||
* LOG_LOCAL_LEVEL to one of the ESP_LOG_* values, before including
|
||||
@ -145,7 +146,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
|
||||
#ifndef LOG_LOCAL_LEVEL
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_MAXIMUM_LEVEL
|
||||
#else
|
||||
#define LOG_LOCAL_LEVEL CONFIG_BOOTLOADER_LOG_LEVEL
|
||||
#endif
|
||||
@ -279,7 +280,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
|
||||
/** @endcond */
|
||||
|
||||
/// macro to output logs in startup code, before heap allocator and syscalls have been initialized. log at ``ESP_LOG_ERROR`` level. @see ``printf``,``ESP_LOGE``
|
||||
/// macro to output logs in startup code, before heap allocator and syscalls have been initialized. log at ``ESP_LOG_ERROR`` level. @see ``printf``,``ESP_LOGE``,``ESP_DRAM_LOGE``
|
||||
#define ESP_EARLY_LOGE( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_ERROR, E, ##__VA_ARGS__)
|
||||
/// macro to output logs in startup code at ``ESP_LOG_WARN`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf``
|
||||
#define ESP_EARLY_LOGW( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_WARN, W, ##__VA_ARGS__)
|
||||
@ -290,8 +291,16 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
/// macro to output logs in startup code at ``ESP_LOG_VERBOSE`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf``
|
||||
#define ESP_EARLY_LOGV( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_VERBOSE, V, ##__VA_ARGS__)
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#define _ESP_LOG_EARLY_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level))
|
||||
#else
|
||||
/* For early log, there is no log tag filtering. So we want to log only if both the LOG_LOCAL_LEVEL and the
|
||||
currently configured min log level are higher than the log level */
|
||||
#define _ESP_LOG_EARLY_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level) && esp_log_default_level >= (log_level))
|
||||
#endif
|
||||
|
||||
#define ESP_LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
||||
if (LOG_LOCAL_LEVEL >= log_level) { \
|
||||
if (_ESP_LOG_EARLY_ENABLED(log_level)) { \
|
||||
esp_rom_printf(LOG_FORMAT(log_tag_letter, format), esp_log_timestamp(), tag, ##__VA_ARGS__); \
|
||||
}} while(0)
|
||||
|
||||
@ -303,7 +312,9 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
#define ESP_LOGV( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, tag, format, ##__VA_ARGS__)
|
||||
#else
|
||||
/**
|
||||
* macro to output logs at ESP_LOG_ERROR level.
|
||||
* Macro to output logs at ESP_LOG_ERROR level.
|
||||
*
|
||||
* @note This macro cannot be used when interrupts are disabled or inside an ISR. @see ``ESP_DRAM_LOGE``.
|
||||
*
|
||||
* @param tag tag of the log, which can be used to change the log level by ``esp_log_level_set`` at runtime.
|
||||
*
|
||||
@ -359,7 +370,11 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
/**
|
||||
* @brief Macro to output logs when the cache is disabled. log at ``ESP_LOG_ERROR`` level.
|
||||
*
|
||||
* Similar to `ESP_EARLY_LOGE`, the log level cannot be changed by `esp_log_level_set`.
|
||||
* @note Unlike normal logging macros, it's possible to use this macro when interrupts are
|
||||
* disabled or inside an ISR.
|
||||
*
|
||||
* Similar to @see ``ESP_EARLY_LOGE``, the log level cannot be changed per-tag, however
|
||||
* esp_log_level_set("*", level) will set the default level which controls these log lines also.
|
||||
*
|
||||
* Usage: `ESP_DRAM_LOGE(DRAM_STR("my_tag"), "format", or `ESP_DRAM_LOGE(TAG, "format", ...)`,
|
||||
* where TAG is a char* that points to a str in the DRAM.
|
||||
@ -382,7 +397,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
||||
#define _ESP_LOG_DRAM_LOG_FORMAT(letter, format) DRAM_STR(#letter " %s: " format "\n")
|
||||
|
||||
#define ESP_DRAM_LOG_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
||||
if (LOG_LOCAL_LEVEL >= log_level) { \
|
||||
if (_ESP_LOG_EARLY_ENABLED(log_level)) { \
|
||||
esp_rom_printf(_ESP_LOG_DRAM_LOG_FORMAT(log_tag_letter, format), tag, ##__VA_ARGS__); \
|
||||
}} while(0)
|
||||
/** @endcond */
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_LOG_INTERNAL_H__
|
||||
#define __ESP_LOG_INTERNAL_H__
|
||||
|
@ -39,8 +39,13 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "arch/sys_arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif // BYTE_ORDER
|
||||
@ -103,5 +108,8 @@ typedef int sys_prot_t;
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
|
@ -42,6 +42,12 @@ lwip_hook_ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest);
|
||||
#define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route
|
||||
#endif /* CONFIG_LWIP_HOOK_IP6_ROUTE... */
|
||||
|
||||
#if defined(CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM) || defined(CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT)
|
||||
const ip6_addr_t *lwip_hook_nd6_get_gw(struct netif *netif, const ip6_addr_t *dest);
|
||||
|
||||
#define LWIP_HOOK_ND6_GET_GW lwip_hook_nd6_get_gw
|
||||
#endif /* CONFIG_LWIP_HOOK_ND6_GET_GATEWAY... */
|
||||
|
||||
#if defined(CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM) || defined(CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT)
|
||||
int lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err);
|
||||
|
||||
|
@ -249,6 +249,10 @@
|
||||
*/
|
||||
#define DHCP_DOES_ARP_CHECK CONFIG_LWIP_DHCP_DOES_ARP_CHECK
|
||||
|
||||
/**
|
||||
* LWIP_DHCP_DISABLE_CLIENT_ID==1: Do not add option 61 (client-id) to DHCP packets
|
||||
*/
|
||||
#define ESP_DHCP_DISABLE_CLIENT_ID CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID
|
||||
|
||||
/**
|
||||
* CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server
|
||||
@ -453,6 +457,8 @@
|
||||
*/
|
||||
#define LWIP_NETIF_API CONFIG_LWIP_NETIF_API
|
||||
|
||||
#define LWIP_NETIF_STATUS_CALLBACK CONFIG_LWIP_NETIF_STATUS_CALLBACK
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- LOOPIF options ----------
|
||||
@ -688,7 +694,7 @@
|
||||
* Some modems do not support IPV6 addressing in local link and
|
||||
* the only option available is to disable IPV6 address negotiation.
|
||||
*/
|
||||
#define PPP_IPV6_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV6
|
||||
#define PPP_IPV6_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV6
|
||||
|
||||
/**
|
||||
* PPP_NOTIFY_PHASE==1: Support PPP notify phase.
|
||||
@ -957,6 +963,10 @@
|
||||
*/
|
||||
#define LWIP_SOCKET_OFFSET (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS)
|
||||
|
||||
#define LWIP_IPV6_FORWARD CONFIG_LWIP_IPV6_FORWARD
|
||||
|
||||
#define LWIP_IPV6_NUM_ADDRESSES CONFIG_LWIP_IPV6_NUM_ADDRESSES
|
||||
|
||||
/* Enable all Espressif-only options */
|
||||
|
||||
#define ESP_LWIP 1
|
||||
|
@ -144,6 +144,15 @@
|
||||
#undef MBEDTLS_SHA512_ALT
|
||||
#endif
|
||||
|
||||
/* MBEDTLS_MDx_ALT to enable ROM MD support
|
||||
with software fallback.
|
||||
*/
|
||||
#ifdef CONFIG_MBEDTLS_ROM_MD5
|
||||
#define MBEDTLS_MD5_ALT
|
||||
#else
|
||||
#undef MBEDTLS_MD5_ALT
|
||||
#endif
|
||||
|
||||
/* The following MPI (bignum) functions have ESP32 hardware support.
|
||||
For exponential mod, both software and hardware implementation
|
||||
will be compiled. If CONFIG_MBEDTLS_HARDWARE_MPI is enabled, mod APIs
|
||||
@ -2451,6 +2460,21 @@
|
||||
#undef MBEDTLS_THREADING_PTHREAD
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_NIST_KW_C
|
||||
*
|
||||
* Enable AES key wrapping as per NIST
|
||||
*
|
||||
* Requires: MBEDTLS_AES_C
|
||||
*
|
||||
* Uncomment this to enable aes key wrap.
|
||||
*/
|
||||
#ifdef CONFIG_MBEDTLS_NIST_KW_C
|
||||
#define MBEDTLS_NIST_KW_C
|
||||
#else
|
||||
#undef MBEDTLS_NIST_KW_C
|
||||
#endif
|
||||
|
||||
/* \} name SECTION: Module configuration options */
|
||||
|
||||
#if defined(TARGET_LIKE_MBED)
|
||||
|
154
tools/sdk/esp32s2/include/mbedtls/port/include/md/esp_md.h
Normal file
154
tools/sdk/esp32s2/include/mbedtls/port/include/md/esp_md.h
Normal file
@ -0,0 +1,154 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_rom_md5.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct MD5Context mbedtls_md5_context;
|
||||
|
||||
/**
|
||||
* \brief Initialize MD5 context
|
||||
*
|
||||
* \param ctx MD5 context to be initialized
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
int esp_md5_init_ret( mbedtls_md5_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Clear MD5 context
|
||||
*
|
||||
* \param ctx MD5 context to be cleared
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
void esp_md5_free( mbedtls_md5_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Clone (the state of) an MD5 context
|
||||
*
|
||||
* \param dst The destination context
|
||||
* \param src The context to be cloned
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
void esp_md5_clone( mbedtls_md5_context *dst, const mbedtls_md5_context *src );
|
||||
|
||||
/**
|
||||
* \brief MD5 process buffer
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*
|
||||
* \return 0 if successful
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
int esp_md5_update_ret( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen );
|
||||
|
||||
/**
|
||||
* \brief MD5 final digest
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param output MD5 checksum result
|
||||
*
|
||||
* \return 0 if successful
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
int esp_md5_finish_ret( mbedtls_md5_context *ctx, unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief MD5 process data block (internal use only)
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param data buffer holding one block of data
|
||||
*
|
||||
* \return 0 if successful
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
int esp_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] );
|
||||
|
||||
/**
|
||||
* \brief MD5 context setup
|
||||
*
|
||||
* \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
void esp_md5_init( mbedtls_md5_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief MD5 process buffer
|
||||
*
|
||||
* \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
void esp_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen );
|
||||
|
||||
/**
|
||||
* \brief MD5 final digest
|
||||
*
|
||||
* \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param output MD5 checksum result
|
||||
*
|
||||
* \warning MD5 is considered a weak message digest and its use
|
||||
* constitutes a security risk. We recommend considering
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
void esp_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
50
tools/sdk/esp32s2/include/mbedtls/port/include/md5_alt.h
Normal file
50
tools/sdk/esp32s2/include/mbedtls/port/include/md5_alt.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* \file md5_alt.h
|
||||
*
|
||||
* \brief MD5 block cipher
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef MD5_ALT_H
|
||||
#define MD5_ALT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MD5_ALT)
|
||||
#include "md/esp_md.h"
|
||||
|
||||
#define mbedtls_md5_init esp_md5_init
|
||||
#define mbedtls_md5_update esp_md5_update
|
||||
#define mbedtls_md5_finish esp_md5_finish
|
||||
#define mbedtls_md5_starts_ret esp_md5_init_ret
|
||||
#define mbedtls_md5_update_ret esp_md5_update_ret
|
||||
#define mbedtls_md5_finish_ret esp_md5_finish_ret
|
||||
|
||||
#define mbedtls_md5_free esp_md5_free
|
||||
#define mbedtls_md5_clone esp_md5_clone
|
||||
#define mbedtls_internal_md5_process esp_md5_process
|
||||
|
||||
#endif /* MBEDTLS_MD5_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -42,7 +42,12 @@ struct dirent {
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_REG 1
|
||||
#define DT_DIR 2
|
||||
char d_name[256]; /*!< zero-terminated file name */
|
||||
#if __BSD_VISIBLE
|
||||
#define MAXNAMLEN 255
|
||||
char d_name[MAXNAMLEN+1]; /*!< zero-terminated file name */
|
||||
#else
|
||||
char d_name[256];
|
||||
#endif
|
||||
};
|
||||
|
||||
DIR* opendir(const char* name);
|
||||
|
@ -113,6 +113,9 @@ extern "C" {
|
||||
#define RTC_CNTL_CK8M_DFREQ_DEFAULT 172
|
||||
#define RTC_CNTL_SCK_DCAP_DEFAULT 255
|
||||
|
||||
#define RTC_CNTL_ULPCP_TOUCH_START_WAIT_IN_SLEEP (0xFF)
|
||||
#define RTC_CNTL_ULPCP_TOUCH_START_WAIT_DEFAULT (0x10)
|
||||
|
||||
/*
|
||||
set sleep_init default param
|
||||
*/
|
||||
|
@ -149,7 +149,7 @@
|
||||
/*-------------------------- MPU CAPS ----------------------------------------*/
|
||||
//TODO: correct the caller and remove unsupported lines
|
||||
#define SOC_MPU_CONFIGURABLE_REGIONS_SUPPORTED 0
|
||||
#define SOC_MPU_MIN_REGION_SIZE 0x20000000
|
||||
#define SOC_MPU_MIN_REGION_SIZE 0x20000000U
|
||||
#define SOC_MPU_REGIONS_MAX_NUM 8
|
||||
#define SOC_MPU_REGION_RO_SUPPORTED 0
|
||||
#define SOC_MPU_REGION_WO_SUPPORTED 0
|
||||
@ -210,10 +210,9 @@
|
||||
|
||||
#define SOC_MEMSPI_IS_INDEPENDENT 1
|
||||
|
||||
/*-------------------------- SYS TIMER CAPS ----------------------------------*/
|
||||
#define SOC_SYSTIMER_COUNTER_NUM (1) // Number of counter units
|
||||
#define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units
|
||||
|
||||
/*-------------------------- SYSTIMER CAPS ----------------------------------*/
|
||||
#define SOC_SYSTIMER_COUNTER_NUM (1) // Number of counter units
|
||||
#define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units
|
||||
#define SOC_SYSTIMER_BIT_WIDTH_LO (32) // Bit width of systimer low part
|
||||
#define SOC_SYSTIMER_BIT_WIDTH_HI (32) // Bit width of systimer high part
|
||||
|
||||
@ -291,6 +290,9 @@
|
||||
#define SOC_AES_SUPPORT_DMA (1)
|
||||
#define SOC_AES_SUPPORT_GCM (1)
|
||||
|
||||
/*-------------------------- Flash Encryption CAPS----------------------------*/
|
||||
#define SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX (64)
|
||||
|
||||
/* Has "crypto DMA", which is shared with SHA */
|
||||
#define SOC_AES_CRYPTO_DMA (1)
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/** Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
@ -38,7 +39,6 @@ extern "C" {
|
||||
#define SYSTIMER_CLK_EN_V 0x00000001
|
||||
#define SYSTIMER_CLK_EN_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_LOAD_REG register
|
||||
* load value to system timer
|
||||
*/
|
||||
@ -51,12 +51,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_LOAD_V 0x00000001
|
||||
#define SYSTIMER_TIMER_LOAD_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_LOAD_HI_REG register
|
||||
* High 32-bit load to system timer
|
||||
*/
|
||||
#define SYSTIMER_LOAD_HI_REG (DR_REG_SYSTIMER_BASE + 0x8)
|
||||
/** SYSTIMER_TIMER_LOAD_HI : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_LOAD_HI : R/W; bitpos: [31:0]; default: 0;
|
||||
* High 32-bit load to system timer
|
||||
*/
|
||||
#define SYSTIMER_TIMER_LOAD_HI 0xFFFFFFFF
|
||||
@ -64,12 +63,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_LOAD_HI_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_LOAD_HI_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_LOAD_LO_REG register
|
||||
* Low 32-bit load to system timer
|
||||
*/
|
||||
#define SYSTIMER_LOAD_LO_REG (DR_REG_SYSTIMER_BASE + 0xc)
|
||||
/** SYSTIMER_TIMER_LOAD_LO : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_LOAD_LO : R/W; bitpos: [31:0]; default: 0;
|
||||
* Low 32-bit load to system timer
|
||||
*/
|
||||
#define SYSTIMER_TIMER_LOAD_LO 0xFFFFFFFF
|
||||
@ -77,19 +75,18 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_LOAD_LO_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_LOAD_LO_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_STEP_REG register
|
||||
* system timer accumulation step
|
||||
*/
|
||||
#define SYSTIMER_STEP_REG (DR_REG_SYSTIMER_BASE + 0x10)
|
||||
/** SYSTIMER_TIMER_XTAL_STEP : R/W; bitpos: [10:0]; default: 80;
|
||||
/** SYSTIMER_TIMER_XTAL_STEP : R/W; bitpos: [9:0]; default: 80;
|
||||
* system timer accumulation step when using XTAL
|
||||
*/
|
||||
#define SYSTIMER_TIMER_XTAL_STEP 0x000003FF
|
||||
#define SYSTIMER_TIMER_XTAL_STEP_M (SYSTIMER_TIMER_XTAL_STEP_V << SYSTIMER_TIMER_XTAL_STEP_S)
|
||||
#define SYSTIMER_TIMER_XTAL_STEP_V 0x000003FF
|
||||
#define SYSTIMER_TIMER_XTAL_STEP_S 0
|
||||
/** SYSTIMER_TIMER_PLL_STEP : R/W; bitpos: [20:10]; default: 1;
|
||||
/** SYSTIMER_TIMER_PLL_STEP : R/W; bitpos: [19:10]; default: 1;
|
||||
* system timer accumulation step when using PLL
|
||||
*/
|
||||
#define SYSTIMER_TIMER_PLL_STEP 0x000003FF
|
||||
@ -97,12 +94,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_PLL_STEP_V 0x000003FF
|
||||
#define SYSTIMER_TIMER_PLL_STEP_S 10
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET0_HI_REG register
|
||||
* System timer target0 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET0_HI_REG (DR_REG_SYSTIMER_BASE + 0x14)
|
||||
/** SYSTIMER_TIMER_TARGET0_HI : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET0_HI : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target0 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET0_HI 0xFFFFFFFF
|
||||
@ -110,12 +106,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET0_HI_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET0_HI_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET0_LO_REG register
|
||||
* System timer target0 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET0_LO_REG (DR_REG_SYSTIMER_BASE + 0x18)
|
||||
/** SYSTIMER_TIMER_TARGET0_LO : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET0_LO : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target0 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET0_LO 0xFFFFFFFF
|
||||
@ -123,12 +118,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET0_LO_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET0_LO_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET1_HI_REG register
|
||||
* System timer target1 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET1_HI_REG (DR_REG_SYSTIMER_BASE + 0x1c)
|
||||
/** SYSTIMER_TIMER_TARGET1_HI : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET1_HI : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target1 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET1_HI 0xFFFFFFFF
|
||||
@ -136,12 +130,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET1_HI_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET1_HI_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET1_LO_REG register
|
||||
* System timer target1 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET1_LO_REG (DR_REG_SYSTIMER_BASE + 0x20)
|
||||
/** SYSTIMER_TIMER_TARGET1_LO : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET1_LO : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target1 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET1_LO 0xFFFFFFFF
|
||||
@ -149,12 +142,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET1_LO_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET1_LO_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET2_HI_REG register
|
||||
* System timer target2 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET2_HI_REG (DR_REG_SYSTIMER_BASE + 0x24)
|
||||
/** SYSTIMER_TIMER_TARGET2_HI : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET2_HI : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target2 high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET2_HI 0xFFFFFFFF
|
||||
@ -162,12 +154,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET2_HI_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET2_HI_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET2_LO_REG register
|
||||
* System timer target2 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TARGET2_LO_REG (DR_REG_SYSTIMER_BASE + 0x28)
|
||||
/** SYSTIMER_TIMER_TARGET2_LO : R/W; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_TARGET2_LO : R/W; bitpos: [31:0]; default: 0;
|
||||
* System timer target2 low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_TARGET2_LO 0xFFFFFFFF
|
||||
@ -175,12 +166,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_TARGET2_LO_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_TARGET2_LO_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET0_CONF_REG register
|
||||
* Configure system timer target0 work mode
|
||||
*/
|
||||
#define SYSTIMER_TARGET0_CONF_REG (DR_REG_SYSTIMER_BASE + 0x2c)
|
||||
/** SYSTIMER_TARGET0_PERIOD : R/W; bitpos: [30:0]; default: 0;
|
||||
/** SYSTIMER_TARGET0_PERIOD : R/W; bitpos: [29:0]; default: 0;
|
||||
* System timer target0 alarm period
|
||||
*/
|
||||
#define SYSTIMER_TARGET0_PERIOD 0x3FFFFFFF
|
||||
@ -202,12 +192,11 @@ extern "C" {
|
||||
#define SYSTIMER_TARGET0_WORK_EN_V 0x00000001
|
||||
#define SYSTIMER_TARGET0_WORK_EN_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET1_CONF_REG register
|
||||
* Configure system timer target1 work mode
|
||||
*/
|
||||
#define SYSTIMER_TARGET1_CONF_REG (DR_REG_SYSTIMER_BASE + 0x30)
|
||||
/** SYSTIMER_TARGET1_PERIOD : R/W; bitpos: [30:0]; default: 0;
|
||||
/** SYSTIMER_TARGET1_PERIOD : R/W; bitpos: [29:0]; default: 0;
|
||||
* System timer target1 alarm period
|
||||
*/
|
||||
#define SYSTIMER_TARGET1_PERIOD 0x3FFFFFFF
|
||||
@ -229,12 +218,11 @@ extern "C" {
|
||||
#define SYSTIMER_TARGET1_WORK_EN_V 0x00000001
|
||||
#define SYSTIMER_TARGET1_WORK_EN_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_TARGET2_CONF_REG register
|
||||
* Configure system timer target2 work mode
|
||||
*/
|
||||
#define SYSTIMER_TARGET2_CONF_REG (DR_REG_SYSTIMER_BASE + 0x34)
|
||||
/** SYSTIMER_TARGET2_PERIOD : R/W; bitpos: [30:0]; default: 0;
|
||||
/** SYSTIMER_TARGET2_PERIOD : R/W; bitpos: [29:0]; default: 0;
|
||||
* System timer target2 alarm period
|
||||
*/
|
||||
#define SYSTIMER_TARGET2_PERIOD 0x3FFFFFFF
|
||||
@ -256,7 +244,6 @@ extern "C" {
|
||||
#define SYSTIMER_TARGET2_WORK_EN_V 0x00000001
|
||||
#define SYSTIMER_TARGET2_WORK_EN_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_UPDATE_REG register
|
||||
* Read out system timer value
|
||||
*/
|
||||
@ -276,12 +263,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_UPDATE_V 0x00000001
|
||||
#define SYSTIMER_TIMER_UPDATE_S 31
|
||||
|
||||
|
||||
/** SYSTIMER_VALUE_HI_REG register
|
||||
* system timer high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_VALUE_HI_REG (DR_REG_SYSTIMER_BASE + 0x3c)
|
||||
/** SYSTIMER_TIMER_VALUE_HI : RO; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_VALUE_HI : RO; bitpos: [31:0]; default: 0;
|
||||
* system timer high 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_VALUE_HI 0xFFFFFFFF
|
||||
@ -289,12 +275,11 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_VALUE_HI_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_VALUE_HI_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_VALUE_LO_REG register
|
||||
* system timer low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_VALUE_LO_REG (DR_REG_SYSTIMER_BASE + 0x40)
|
||||
/** SYSTIMER_TIMER_VALUE_LO : RO; bitpos: [32:0]; default: 0;
|
||||
/** SYSTIMER_TIMER_VALUE_LO : RO; bitpos: [31:0]; default: 0;
|
||||
* system timer low 32-bit
|
||||
*/
|
||||
#define SYSTIMER_TIMER_VALUE_LO 0xFFFFFFFF
|
||||
@ -302,93 +287,89 @@ extern "C" {
|
||||
#define SYSTIMER_TIMER_VALUE_LO_V 0xFFFFFFFF
|
||||
#define SYSTIMER_TIMER_VALUE_LO_S 0
|
||||
|
||||
|
||||
/** SYSTIMER_INT_ENA_REG register
|
||||
* system timer interrupt enable
|
||||
*/
|
||||
#define SYSTIMER_INT_ENA_REG (DR_REG_SYSTIMER_BASE + 0x44)
|
||||
/** SYSTIMER_INT0_ENA : R/W; bitpos: [0]; default: 0;
|
||||
/** SYSTIMER_SYSTIMER_INT0_ENA : R/W; bitpos: [0]; default: 0;
|
||||
* system timer target0 interrupt enable
|
||||
*/
|
||||
#define SYSTIMER_INT0_ENA (BIT(0))
|
||||
#define SYSTIMER_INT0_ENA_M (SYSTIMER_INT0_ENA_V << SYSTIMER_INT0_ENA_S)
|
||||
#define SYSTIMER_INT0_ENA_V 0x00000001
|
||||
#define SYSTIMER_INT0_ENA_S 0
|
||||
/** SYSTIMER_INT1_ENA : R/W; bitpos: [1]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT0_ENA (BIT(0))
|
||||
#define SYSTIMER_SYSTIMER_INT0_ENA_M (SYSTIMER_SYSTIMER_INT0_ENA_V << SYSTIMER_SYSTIMER_INT0_ENA_S)
|
||||
#define SYSTIMER_SYSTIMER_INT0_ENA_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT0_ENA_S 0
|
||||
/** SYSTIMER_SYSTIMER_INT1_ENA : R/W; bitpos: [1]; default: 0;
|
||||
* system timer target1 interrupt enable
|
||||
*/
|
||||
#define SYSTIMER_INT1_ENA (BIT(1))
|
||||
#define SYSTIMER_INT1_ENA_M (SYSTIMER_INT1_ENA_V << SYSTIMER_INT1_ENA_S)
|
||||
#define SYSTIMER_INT1_ENA_V 0x00000001
|
||||
#define SYSTIMER_INT1_ENA_S 1
|
||||
/** SYSTIMER_INT2_ENA : R/W; bitpos: [2]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT1_ENA (BIT(1))
|
||||
#define SYSTIMER_SYSTIMER_INT1_ENA_M (SYSTIMER_SYSTIMER_INT1_ENA_V << SYSTIMER_SYSTIMER_INT1_ENA_S)
|
||||
#define SYSTIMER_SYSTIMER_INT1_ENA_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT1_ENA_S 1
|
||||
/** SYSTIMER_SYSTIMER_INT2_ENA : R/W; bitpos: [2]; default: 0;
|
||||
* system timer target2 interrupt enable
|
||||
*/
|
||||
#define SYSTIMER_INT2_ENA (BIT(2))
|
||||
#define SYSTIMER_INT2_ENA_M (SYSTIMER_INT2_ENA_V << SYSTIMER_INT2_ENA_S)
|
||||
#define SYSTIMER_INT2_ENA_V 0x00000001
|
||||
#define SYSTIMER_INT2_ENA_S 2
|
||||
|
||||
#define SYSTIMER_SYSTIMER_INT2_ENA (BIT(2))
|
||||
#define SYSTIMER_SYSTIMER_INT2_ENA_M (SYSTIMER_SYSTIMER_INT2_ENA_V << SYSTIMER_SYSTIMER_INT2_ENA_S)
|
||||
#define SYSTIMER_SYSTIMER_INT2_ENA_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT2_ENA_S 2
|
||||
|
||||
/** SYSTIMER_INT_RAW_REG register
|
||||
* system timer interrupt raw
|
||||
*/
|
||||
#define SYSTIMER_INT_RAW_REG (DR_REG_SYSTIMER_BASE + 0x48)
|
||||
/** SYSTIMER_INT0_RAW : RO; bitpos: [0]; default: 0;
|
||||
/** SYSTIMER_SYSTIMER_INT0_RAW : RO; bitpos: [0]; default: 0;
|
||||
* system timer target0 interrupt raw
|
||||
*/
|
||||
#define SYSTIMER_INT0_RAW (BIT(0))
|
||||
#define SYSTIMER_INT0_RAW_M (SYSTIMER_INT0_RAW_V << SYSTIMER_INT0_RAW_S)
|
||||
#define SYSTIMER_INT0_RAW_V 0x00000001
|
||||
#define SYSTIMER_INT0_RAW_S 0
|
||||
/** SYSTIMER_INT1_RAW : RO; bitpos: [1]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT0_RAW (BIT(0))
|
||||
#define SYSTIMER_SYSTIMER_INT0_RAW_M (SYSTIMER_SYSTIMER_INT0_RAW_V << SYSTIMER_SYSTIMER_INT0_RAW_S)
|
||||
#define SYSTIMER_SYSTIMER_INT0_RAW_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT0_RAW_S 0
|
||||
/** SYSTIMER_SYSTIMER_INT1_RAW : RO; bitpos: [1]; default: 0;
|
||||
* system timer target1 interrupt raw
|
||||
*/
|
||||
#define SYSTIMER_INT1_RAW (BIT(1))
|
||||
#define SYSTIMER_INT1_RAW_M (SYSTIMER_INT1_RAW_V << SYSTIMER_INT1_RAW_S)
|
||||
#define SYSTIMER_INT1_RAW_V 0x00000001
|
||||
#define SYSTIMER_INT1_RAW_S 1
|
||||
/** SYSTIMER_INT2_RAW : RO; bitpos: [2]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT1_RAW (BIT(1))
|
||||
#define SYSTIMER_SYSTIMER_INT1_RAW_M (SYSTIMER_SYSTIMER_INT1_RAW_V << SYSTIMER_SYSTIMER_INT1_RAW_S)
|
||||
#define SYSTIMER_SYSTIMER_INT1_RAW_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT1_RAW_S 1
|
||||
/** SYSTIMER_SYSTIMER_INT2_RAW : RO; bitpos: [2]; default: 0;
|
||||
* system timer target2 interrupt raw
|
||||
*/
|
||||
#define SYSTIMER_INT2_RAW (BIT(2))
|
||||
#define SYSTIMER_INT2_RAW_M (SYSTIMER_INT2_RAW_V << SYSTIMER_INT2_RAW_S)
|
||||
#define SYSTIMER_INT2_RAW_V 0x00000001
|
||||
#define SYSTIMER_INT2_RAW_S 2
|
||||
|
||||
#define SYSTIMER_SYSTIMER_INT2_RAW (BIT(2))
|
||||
#define SYSTIMER_SYSTIMER_INT2_RAW_M (SYSTIMER_SYSTIMER_INT2_RAW_V << SYSTIMER_SYSTIMER_INT2_RAW_S)
|
||||
#define SYSTIMER_SYSTIMER_INT2_RAW_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT2_RAW_S 2
|
||||
|
||||
/** SYSTIMER_INT_CLR_REG register
|
||||
* system timer interrupt clear
|
||||
*/
|
||||
#define SYSTIMER_INT_CLR_REG (DR_REG_SYSTIMER_BASE + 0x4c)
|
||||
/** SYSTIMER_INT0_CLR : WO; bitpos: [0]; default: 0;
|
||||
/** SYSTIMER_SYSTIMER_INT0_CLR : WO; bitpos: [0]; default: 0;
|
||||
* system timer target0 interrupt clear
|
||||
*/
|
||||
#define SYSTIMER_INT0_CLR (BIT(0))
|
||||
#define SYSTIMER_INT0_CLR_M (SYSTIMER_INT0_CLR_V << SYSTIMER_INT0_CLR_S)
|
||||
#define SYSTIMER_INT0_CLR_V 0x00000001
|
||||
#define SYSTIMER_INT0_CLR_S 0
|
||||
/** SYSTIMER_INT1_CLR : WO; bitpos: [1]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT0_CLR (BIT(0))
|
||||
#define SYSTIMER_SYSTIMER_INT0_CLR_M (SYSTIMER_SYSTIMER_INT0_CLR_V << SYSTIMER_SYSTIMER_INT0_CLR_S)
|
||||
#define SYSTIMER_SYSTIMER_INT0_CLR_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT0_CLR_S 0
|
||||
/** SYSTIMER_SYSTIMER_INT1_CLR : WO; bitpos: [1]; default: 0;
|
||||
* system timer target1 interrupt clear
|
||||
*/
|
||||
#define SYSTIMER_INT1_CLR (BIT(1))
|
||||
#define SYSTIMER_INT1_CLR_M (SYSTIMER_INT1_CLR_V << SYSTIMER_INT1_CLR_S)
|
||||
#define SYSTIMER_INT1_CLR_V 0x00000001
|
||||
#define SYSTIMER_INT1_CLR_S 1
|
||||
/** SYSTIMER_INT2_CLR : WO; bitpos: [2]; default: 0;
|
||||
#define SYSTIMER_SYSTIMER_INT1_CLR (BIT(1))
|
||||
#define SYSTIMER_SYSTIMER_INT1_CLR_M (SYSTIMER_SYSTIMER_INT1_CLR_V << SYSTIMER_SYSTIMER_INT1_CLR_S)
|
||||
#define SYSTIMER_SYSTIMER_INT1_CLR_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT1_CLR_S 1
|
||||
/** SYSTIMER_SYSTIMER_INT2_CLR : WO; bitpos: [2]; default: 0;
|
||||
* system timer target2 interrupt clear
|
||||
*/
|
||||
#define SYSTIMER_INT2_CLR (BIT(2))
|
||||
#define SYSTIMER_INT2_CLR_M (SYSTIMER_INT2_CLR_V << SYSTIMER_INT2_CLR_S)
|
||||
#define SYSTIMER_INT2_CLR_V 0x00000001
|
||||
#define SYSTIMER_INT2_CLR_S 2
|
||||
|
||||
#define SYSTIMER_SYSTIMER_INT2_CLR (BIT(2))
|
||||
#define SYSTIMER_SYSTIMER_INT2_CLR_M (SYSTIMER_SYSTIMER_INT2_CLR_V << SYSTIMER_SYSTIMER_INT2_CLR_S)
|
||||
#define SYSTIMER_SYSTIMER_INT2_CLR_V 0x00000001
|
||||
#define SYSTIMER_SYSTIMER_INT2_CLR_S 2
|
||||
|
||||
/** SYSTIMER_DATE_REG register
|
||||
* system timer register version
|
||||
*/
|
||||
#define SYSTIMER_DATE_REG (DR_REG_SYSTIMER_BASE + 0xfc)
|
||||
/** SYSTIMER_DATE : R/W; bitpos: [32:0]; default: 25194848;
|
||||
/** SYSTIMER_DATE : R/W; bitpos: [31:0]; default: 25194848;
|
||||
* system timer register version
|
||||
*/
|
||||
#define SYSTIMER_DATE 0xFFFFFFFF
|
||||
@ -396,7 +377,6 @@ extern "C" {
|
||||
#define SYSTIMER_DATE_V 0xFFFFFFFF
|
||||
#define SYSTIMER_DATE_S 0
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user