forked from espressif/arduino-esp32
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
29
tools/sdk/esp32/include/perfmon/include/perfmon.h
Normal file
29
tools/sdk/esp32/include/perfmon/include/perfmon.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2018-2019 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 _PERF_MON_H_
|
||||
#define _PERF_MON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "xtensa_perfmon_access.h"
|
||||
#include "xtensa_perfmon_masks.h"
|
||||
#include "xtensa_perfmon_apis.h"
|
||||
#include "xtensa/xt_perf_consts.h"
|
||||
|
||||
#endif // _PERF_MON_H_
|
125
tools/sdk/esp32/include/perfmon/include/xtensa_perfmon_access.h
Normal file
125
tools/sdk/esp32/include/perfmon/include/xtensa_perfmon_access.h
Normal file
@ -0,0 +1,125 @@
|
||||
// Copyright 2018-2019 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 _PERF_MON_ACCESS_H_
|
||||
#define _PERF_MON_ACCESS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Init Performance Monitoor
|
||||
*
|
||||
* Initialize performance monitor register with define values
|
||||
*
|
||||
* @param[in] id: performance counter number
|
||||
* @param[in] select: select value from PMCTRLx register
|
||||
* @param[in] mask: mask value from PMCTRLx register
|
||||
* @param[in] kernelcnt: kernelcnt value from PMCTRLx register
|
||||
* @param[in] tracelevel: tracelevel value from PMCTRLx register
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if one of the arguments is not correct
|
||||
*/
|
||||
esp_err_t xtensa_perfmon_init(int id, uint16_t select, uint16_t mask, int kernelcnt, int tracelevel);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Reset PM counter
|
||||
*
|
||||
* Reset PM counter. Writes 0 to the PMx register.
|
||||
*
|
||||
* @param[in] id: performance counter number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if id out of range
|
||||
*/
|
||||
esp_err_t xtensa_perfmon_reset(int id);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Start PM counters
|
||||
*
|
||||
* Start all PM counters synchronously. Write 1 to the PGM register
|
||||
*/
|
||||
void xtensa_perfmon_start(void);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Stop PM counters
|
||||
*
|
||||
* Stop all PM counters synchronously. Write 0 to the PGM register
|
||||
*/
|
||||
void xtensa_perfmon_stop(void);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Read PM counter
|
||||
*
|
||||
* Read value of defined PM counter.
|
||||
*
|
||||
* @param[in] id: performance counter number
|
||||
*
|
||||
* @return
|
||||
* - Performance counter value
|
||||
*/
|
||||
uint32_t xtensa_perfmon_value(int id);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Read PM overflow state
|
||||
*
|
||||
* Read overflow value of defined PM counter.
|
||||
*
|
||||
* @param[in] id: performance counter number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if there is no overflow (overflow = 0)
|
||||
* - ESP_FAIL if overflow occure (overflow = 1)
|
||||
*/
|
||||
esp_err_t xtensa_perfmon_overflow(int id);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Dump PM values
|
||||
*
|
||||
* Dump all PM register to the console.
|
||||
*
|
||||
*/
|
||||
void xtensa_perfmon_dump(void);
|
||||
/**@}*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _PERF_MON_ACCESS_H_
|
@ -0,0 +1,80 @@
|
||||
// Copyright 2018-2019 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 _xtensa_perfmon_apis_H_
|
||||
#define _xtensa_perfmon_apis_H_
|
||||
#include "xtensa_perfmon_access.h"
|
||||
#include "xtensa_perfmon_masks.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Performance monitor configuration structure
|
||||
*
|
||||
* Structure to configure performance counter to measure dedicated function
|
||||
*/
|
||||
typedef struct xtensa_perfmon_config {
|
||||
int repeat_count; /*!< how much times function will be called before the calback will be repeated */
|
||||
float max_deviation; /*!< Difference between min and max counter number 0..1, 0 - no difference, 1 - not used */
|
||||
void *call_params; /*!< This pointer will be passed to the call_function as a parameter */
|
||||
void (*call_function)(void *params); /*!< pointer to the function that have to be called */
|
||||
void (*callback)(void *params, uint32_t select, uint32_t mask, uint32_t value); /*!< pointer to the function that will be called with result parameters */
|
||||
void *callback_params; /*!< parameter that will be passed to the callback */
|
||||
int tracelevel; /*!< trace level for all counters.
|
||||
In case of negative value, the filter will be ignored.
|
||||
If it's >=0, then the perfmon will count only when interrupt level > tracelevel. It's useful to monitor interrupts. */
|
||||
uint32_t counters_size;/*!< amount of counter in the list */
|
||||
const uint32_t *select_mask; /*!< list of the select/mask parameters */
|
||||
} xtensa_perfmon_config_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Execute PM
|
||||
*
|
||||
* Execute performance counter for dedicated function with defined parameters
|
||||
*
|
||||
* @param[in] config: pointer to the configuration structure
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if no errors
|
||||
* - ESP_ERR_INVALID_ARG if one of the required parameters not defined
|
||||
* - ESP_FAIL - counter overflow
|
||||
*/
|
||||
esp_err_t xtensa_perfmon_exec(const xtensa_perfmon_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Dump PM results
|
||||
*
|
||||
* Callback to dump perfmon result to a FILE* stream specified in
|
||||
* perfmon_config_t::callback_params. If callback_params is set to NULL, will print to stdout
|
||||
*
|
||||
* @param[in] params: used parameters passed from configuration (callback_params).
|
||||
* This parameter expected as FILE* hanle, where data will be stored.
|
||||
* If this parameter NULL, then data will be stored to the stdout.
|
||||
* @param[in] select: select value for current counter
|
||||
* @param[in] mask: mask value for current counter
|
||||
* @param[in] value: counter value for current counter
|
||||
*
|
||||
*/
|
||||
void xtensa_perfmon_view_cb(void *params, uint32_t select, uint32_t mask, uint32_t value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _xtensa_perfmon_apis_H_
|
@ -0,0 +1,74 @@
|
||||
|
||||
// Copyright 2018-2019 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 _xtensa_perfmon_masks_H_
|
||||
#define _xtensa_perfmon_masks_H_
|
||||
#include <inttypes.h>
|
||||
#include "xtensa/xt_perf_consts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Description for select parameter
|
||||
*
|
||||
* Structure defines description for different select values for performance counters
|
||||
*/
|
||||
typedef struct xtensa_perfmon_select {
|
||||
int select; /*!< Selected counter */
|
||||
const char *description; /*!< Description for selected counter */
|
||||
} xtensa_perfmon_select_t;
|
||||
|
||||
/**
|
||||
* @brief Description for mask parameter
|
||||
*
|
||||
* Structure defines description for different select and mask values for performance counters
|
||||
*/
|
||||
typedef struct xtensa_perfmon_masks {
|
||||
int select; /*!< Selected counter */
|
||||
int mask; /*!< Selected mask for counter */
|
||||
const char *description; /*!< Description for selected mask */
|
||||
} xtensa_perfmon_masks_t;
|
||||
|
||||
// Maximum amount of performance counter events
|
||||
#define MAX_PERFMON_EVENTS 119
|
||||
|
||||
/**
|
||||
* @brief Select value description table
|
||||
*
|
||||
* Table contains description for different 'select' values for performance counter
|
||||
*/
|
||||
extern const xtensa_perfmon_select_t xtensa_perfmon_select_table[];
|
||||
|
||||
/**
|
||||
* @brief Mask value description table
|
||||
*
|
||||
* Table contains description for different 'select' and 'mask' values for performance counter
|
||||
*/
|
||||
extern const xtensa_perfmon_masks_t xtensa_perfmon_masks_table[];
|
||||
|
||||
/**
|
||||
* @brief All available counters
|
||||
*
|
||||
* Table contains all available counters
|
||||
*/
|
||||
extern const uint32_t xtensa_perfmon_select_mask_all[MAX_PERFMON_EVENTS * 2];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _xtensa_perfmon_masks_H_
|
Reference in New Issue
Block a user