Imported more library files

Not compiling currently
This commit is contained in:
2025-04-12 23:37:19 +01:00
parent 264a3462e0
commit 9d06f983af
2518 changed files with 1021900 additions and 52 deletions

View File

@@ -0,0 +1,219 @@
/***************************************************************************//**
* @file
* @brief Board Control API
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_BOARD_CONTROL_H
#define SL_BOARD_CONTROL_H
#include "sl_status.h"
#include "sl_enum.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup board_control Board Control
* @brief Functions to control Silicon Labs board features
* @{
******************************************************************************/
/// Board Sensor Type
SL_ENUM_GENERIC(sl_board_sensor_t, int) {
SL_BOARD_SENSOR_RHT = (1UL << 0UL), ///< Relative Humidity and Temperature Sensor
SL_BOARD_SENSOR_LIGHT = (1UL << 1UL), ///< UV Index and Ambient Light Sensor
SL_BOARD_SENSOR_PRESSURE = (1UL << 2UL), ///< Barometric Pressure Sensor
SL_BOARD_SENSOR_HALL = (1UL << 3UL), ///< Hall Effect Sensor
SL_BOARD_SENSOR_GAS = (1UL << 4UL), ///< Gas Sensor
SL_BOARD_SENSOR_IMU = (1UL << 5UL), ///< Inertial Measurement Unit (Accelerometer/Gyroscope)
SL_BOARD_SENSOR_MICROPHONE = (1UL << 6UL), ///< Microphone
};
/// Board Memory Type
SL_ENUM_GENERIC(sl_board_memory_t, int) {
SL_BOARD_MEMORY_SDCARD = (1UL << 0UL), ///< SD Card
SL_BOARD_MEMORY_QSPI = (1UL << 1UL), ///< Quad SPI Flash
};
/// Board Oscillator Type
SL_ENUM_GENERIC(sl_board_oscillator_t, int) {
SL_BOARD_OSCILLATOR_TCXO = (1UL << 0UL), ///< TCXO
};
/***************************************************************************//**
* @brief Configure Virtual COM UART.
*
* @return Status code
* @retval SL_STATUS_OK VCOM was successfully enabled
* @retval SL_STATUS_FAIL Enabling VCOM failed
* @retval SL_STATUS_NOT_AVAILABLE VCOM control is not available on this board
* @retval SL_STATUS_NOT_SUPPORTED VCOM enabled was not configured
******************************************************************************/
sl_status_t sl_board_configure_vcom(void);
/***************************************************************************//**
* @brief Enable Virtual COM UART.
*
* @return Status code
* @retval SL_STATUS_OK VCOM was successfully enabled
* @retval SL_STATUS_FAIL Enabling VCOM failed
* @retval SL_STATUS_NOT_AVAILABLE VCOM control is not available on this board
******************************************************************************/
sl_status_t sl_board_enable_vcom(void);
/***************************************************************************//**
* @brief Disable Virtual COM UART.
*
* @return Status code
* @retval SL_STATUS_OK VCOM was successfully disabled
* @retval SL_STATUS_FAIL Disabling VCOM failed
* @retval SL_STATUS_NOT_AVAILABLE VCOM control is not available on this board
******************************************************************************/
sl_status_t sl_board_disable_vcom(void);
/***************************************************************************//**
* @brief Enable a sensor.
*
* @warning
* On boards 4166A, 4184A, and 4184B sensors
* - Pressure Sensor, RH/Temp Sensor, and UV/Ambient Light Sensor;
* - UV/Ambient Light Sensor, Hall-effect Sensor, and RH/Temp Sensor;
* - Ambient Light Sensor, Hall-effect Sensor, and RH/Temp Sensor
* respectively, are tied to the same enable pin. Calling the enable function
* for only one of these sensors has the side-effect of enabling all three;
* and calling the disable function for only one of them has the
* side-effect of disabling all three.
* The latter scenario seems less than desirable.
*
* @param[in] sensor Sensor to enable
*
* @return Status code
* @retval SL_STATUS_OK Sensor was successfully enabled
* @retval SL_STATUS_FAIL Enabling sensor failed
* @retval SL_STATUS_NOT_AVAILABLE Sensor control is not available on this board
******************************************************************************/
sl_status_t sl_board_enable_sensor(sl_board_sensor_t sensor);
/***************************************************************************//**
* @brief Disable a sensor.
*
* @warning
* On boards 4166A, 4184A, and 4184B sensors
* - Pressure Sensor, RH/Temp Sensor, and UV/Ambient Light Sensor;
* - UV/Ambient Light Sensor, Hall-effect Sensor, and RH/Temp Sensor;
* - Ambient Light Sensor, Hall-effect Sensor, and RH/Temp Sensor
* respectively, are tied to the same enable pin. Calling the enable function
* for only one of these sensors has the side-effect of enabling all three;
* and calling the disable function for only one of them has the
* side-effect of disabling all three.
* The latter scenario seems less than desirable.
*
* @param[in] sensor Sensors to disable
*
* @return Status code
* @retval SL_STATUS_OK Sensor was successfully disabled
* @retval SL_STATUS_FAIL Disabling sensor failed
* @retval SL_STATUS_NOT_AVAILABLE Sensor control is not available on this board
******************************************************************************/
sl_status_t sl_board_disable_sensor(sl_board_sensor_t sensor);
/***************************************************************************//**
* @brief Enable display.
*
* @return Status code
* @retval SL_STATUS_OK Display was successfully enabled
* @retval SL_STATUS_FAIL Enabling display failed
* @retval SL_STATUS_NOT_AVAILABLE Display control is not available on this board
******************************************************************************/
sl_status_t sl_board_enable_display(void);
/***************************************************************************//**
* @brief Disable display.
*
* @return Status code
* @retval SL_STATUS_OK Display was successfully disabled
* @retval SL_STATUS_FAIL Disabling display failed
* @retval SL_STATUS_NOT_AVAILABLE Display control is not available on this board
******************************************************************************/
sl_status_t sl_board_disable_display(void);
/***************************************************************************//**
* @brief Enable memory.
*
* @param[in] memory Memory to enable
*
* @return Status code
* @retval SL_STATUS_OK Memory was successfully enabled
* @retval SL_STATUS_FAIL Enabling memory failed
* @retval SL_STATUS_NOT_AVAILABLE Memory control is not available on this board
******************************************************************************/
sl_status_t sl_board_enable_memory(sl_board_memory_t memory);
/***************************************************************************//**
* @brief Disable memory.
*
* @param[in] memory Memory to disable
*
* @return Status code
* @retval SL_STATUS_OK Memory was successfully disabled
* @retval SL_STATUS_FAIL Disabling memory failed
* @retval SL_STATUS_NOT_AVAILABLE Memory control is not available on this board
******************************************************************************/
sl_status_t sl_board_disable_memory(sl_board_memory_t memory);
/***************************************************************************//**
* @brief Enable an oscillator.
*
* @param[in] oscillator Oscillator to enable
*
* @return Status code
* @retval SL_STATUS_OK Oscillator was successfully enabled
* @retval SL_STATUS_FAIL Enabling oscillator failed
* @retval SL_STATUS_NOT_AVAILABLE Oscillator control is not available on this board
******************************************************************************/
sl_status_t sl_board_enable_oscillator(sl_board_oscillator_t oscillator);
/***************************************************************************//**
* @brief Disable a oscillator.
*
* @param[in] oscillator Oscillator to disable
*
* @return Status code
* @retval SL_STATUS_OK Oscillator was successfully disabled
* @retval SL_STATUS_FAIL Disabling oscillator failed
* @retval SL_STATUS_NOT_AVAILABLE Oscillator control is not available on this board
******************************************************************************/
sl_status_t sl_board_disable_oscillator(sl_board_oscillator_t oscillator);
/** @} */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // SL_BOARD_CONTROL_H

View File

@@ -0,0 +1,65 @@
/***************************************************************************//**
* @file
* @brief Board Init
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_BOARD_INIT_H
#define SL_BOARD_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup board_init Board Init
* @brief Initialization of Silicon Labs board features
* @{
******************************************************************************/
/***************************************************************************//**
* @brief Initialize board.
* @details
* Initialize a Silicon Labs board by enabling available and configured board
* features, in addition to performing necessary board errata fixes and setting
* default pin states.
******************************************************************************/
void sl_board_init(void);
/***************************************************************************//**
* @brief Initialize board features that are required at early boot.
* @details
* Certain board features such as external oscillators may need to be powered
* before core device features, such as the clock tree, are configured.
******************************************************************************/
void sl_board_preinit(void);
/** @} */
#ifdef __cplusplus
}
#endif
#endif // SL_BOARD_INIT_H

View File

@@ -0,0 +1,489 @@
/***************************************************************************//**
* @file
* @brief Board Control API
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_board_control.h"
#include "sl_board_control_config.h"
#include "em_device.h"
#include "sl_assert.h"
#include "sl_gpio.h"
sl_status_t sl_board_configure_vcom(void)
{
#if defined(SL_BOARD_ENABLE_VCOM) && SL_BOARD_ENABLE_VCOM
return sl_board_enable_vcom();
#else
return SL_STATUS_NOT_SUPPORTED;
#endif
}
sl_status_t sl_board_enable_vcom(void)
{
#if defined(SL_BOARD_ENABLE_VCOM_PORT)
sl_gpio_t enable_vcom_gpio = {
.port = SL_BOARD_ENABLE_VCOM_PORT,
.pin = SL_BOARD_ENABLE_VCOM_PIN,
};
sl_gpio_set_pin_mode(&enable_vcom_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
return SL_STATUS_OK;
#else
return SL_STATUS_NOT_AVAILABLE;
#endif
}
sl_status_t sl_board_disable_vcom(void)
{
#if defined(SL_BOARD_ENABLE_VCOM_PORT)
sl_gpio_t disable_vcom_gpio = {
.port = SL_BOARD_ENABLE_VCOM_PORT,
.pin = SL_BOARD_ENABLE_VCOM_PIN,
};
sl_gpio_set_pin_mode(&disable_vcom_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
return SL_STATUS_OK;
#else
return SL_STATUS_NOT_AVAILABLE;
#endif
}
sl_status_t sl_board_enable_display(void)
{
#if defined(SL_BOARD_ENABLE_DISPLAY_PORT)
sl_gpio_t enable_display_gpio = {
.port = SL_BOARD_ENABLE_DISPLAY_PORT,
.pin = SL_BOARD_ENABLE_DISPLAY_PIN,
};
sl_gpio_set_pin_mode(&enable_display_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
#if defined(SL_BOARD_SELECT_DISPLAY_PORT)
sl_gpio_t select_display_gpio;
select_display_gpio.port = SL_BOARD_SELECT_DISPLAY_PORT;
select_display_gpio.pin = SL_BOARD_SELECT_DISPLAY_PIN;
sl_gpio_set_pin_mode(&select_display_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
#endif
return SL_STATUS_OK;
#else
return SL_STATUS_NOT_AVAILABLE;
#endif
}
sl_status_t sl_board_disable_display(void)
{
#if defined(SL_BOARD_ENABLE_DISPLAY_PORT)
sl_gpio_t enable_display_gpio = {
.port = SL_BOARD_ENABLE_DISPLAY_PORT,
.pin = SL_BOARD_ENABLE_DISPLAY_PIN,
};
sl_gpio_set_pin_mode(&enable_display_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
#if defined(SL_BOARD_SELECT_DISPLAY_PORT)
sl_gpio_t select_display_gpio;
select_display_gpio.port = SL_BOARD_SELECT_DISPLAY_PORT;
select_display_gpio.pin = SL_BOARD_SELECT_DISPLAY_PIN;
sl_gpio_set_pin_mode(&select_display_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
#endif
return SL_STATUS_OK;
#else
return SL_STATUS_NOT_AVAILABLE;
#endif
}
sl_status_t sl_board_enable_sensor(sl_board_sensor_t sensor)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
#if defined(SL_BOARD_ENABLE_SENSOR_RHT_PORT)
sl_gpio_t enable_sensor_rht_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_RHT_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_RHT_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_LIGHT_PORT)
sl_gpio_t enable_sensor_light_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_LIGHT_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_LIGHT_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT)
sl_gpio_t enable_sensor_pressure_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_PRESSURE_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_HALL_PORT)
sl_gpio_t enable_sensor_hall_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_HALL_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_HALL_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_GAS_PORT)
sl_gpio_t enable_sensor_gas_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_GAS_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_GAS_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_IMU_PORT)
sl_gpio_t enable_sensor_imu_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_IMU_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_IMU_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT)
sl_gpio_t enable_sensor_microphone_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_MICROPHONE_PIN,
};
#endif
switch (sensor) {
case SL_BOARD_SENSOR_RHT:
#if defined(SL_BOARD_ENABLE_SENSOR_RHT_PORT)
sl_gpio_set_pin_mode(&enable_sensor_rht_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_LIGHT:
#if defined(SL_BOARD_ENABLE_SENSOR_LIGHT_PORT)
sl_gpio_set_pin_mode(&enable_sensor_light_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_PRESSURE:
#if defined(SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT)
sl_gpio_set_pin_mode(&enable_sensor_pressure_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_HALL:
#if defined(SL_BOARD_ENABLE_SENSOR_HALL_PORT)
sl_gpio_set_pin_mode(&enable_sensor_hall_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_GAS:
#if defined(SL_BOARD_ENABLE_SENSOR_GAS_PORT)
sl_gpio_set_pin_mode(&enable_sensor_gas_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_IMU:
#if defined(SL_BOARD_ENABLE_SENSOR_IMU_PORT)
sl_gpio_set_pin_mode(&enable_sensor_imu_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_MICROPHONE:
#if defined(SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT)
sl_gpio_set_pin_mode(&enable_sensor_microphone_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}
sl_status_t sl_board_disable_sensor(sl_board_sensor_t sensor)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
#if defined(SL_BOARD_ENABLE_SENSOR_RHT_PORT)
sl_gpio_t enable_sensor_rht_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_RHT_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_RHT_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_LIGHT_PORT)
sl_gpio_t enable_sensor_light_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_LIGHT_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_LIGHT_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT)
sl_gpio_t enable_sensor_pressure_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_PRESSURE_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_HALL_PORT)
sl_gpio_t enable_sensor_hall_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_HALL_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_HALL_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_GAS_PORT)
sl_gpio_t enable_sensor_gas_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_GAS_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_GAS_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_IMU_PORT)
sl_gpio_t enable_sensor_imu_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_IMU_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_IMU_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT)
sl_gpio_t enable_sensor_microphone_gpio = {
.port = SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT,
.pin = SL_BOARD_ENABLE_SENSOR_MICROPHONE_PIN,
};
#endif
switch (sensor) {
case SL_BOARD_SENSOR_RHT:
#if defined(SL_BOARD_ENABLE_SENSOR_RHT_PORT)
sl_gpio_set_pin_mode(&enable_sensor_rht_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_LIGHT:
#if defined(SL_BOARD_ENABLE_SENSOR_LIGHT_PORT)
sl_gpio_set_pin_mode(&enable_sensor_light_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_PRESSURE:
#if defined(SL_BOARD_ENABLE_SENSOR_PRESSURE_PORT)
sl_gpio_set_pin_mode(&enable_sensor_pressure_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_HALL:
#if defined(SL_BOARD_ENABLE_SENSOR_HALL_PORT)
sl_gpio_set_pin_mode(&enable_sensor_hall_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_GAS:
#if defined(SL_BOARD_ENABLE_SENSOR_GAS_PORT)
sl_gpio_set_pin_mode(&enable_sensor_gas_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_IMU:
#if defined(SL_BOARD_ENABLE_SENSOR_IMU_PORT)
sl_gpio_set_pin_mode(&enable_sensor_imu_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_SENSOR_MICROPHONE:
#if defined(SL_BOARD_ENABLE_SENSOR_MICROPHONE_PORT)
sl_gpio_set_pin_mode(&enable_sensor_microphone_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}
sl_status_t sl_board_enable_memory(sl_board_memory_t memory)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
#if defined(SL_BOARD_ENABLE_MEMORY_SDCARD_PORT)
sl_gpio_t enable_memory_sdcard_gpio = {
.port = SL_BOARD_ENABLE_MEMORY_SDCARD_PORT,
.pin = SL_BOARD_ENABLE_MEMORY_SDCARD_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_MEMORY_QSPI_PORT)
sl_gpio_t enable_memory_qspi_gpio = {
.port = SL_BOARD_ENABLE_MEMORY_QSPI_PORT,
.pin = SL_BOARD_ENABLE_MEMORY_QSPI_PIN,
};
#endif
switch (memory) {
case SL_BOARD_MEMORY_SDCARD:
#if defined(SL_BOARD_ENABLE_MEMORY_SDCARD_PORT)
sl_gpio_set_pin_mode(&enable_memory_sdcard_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_MEMORY_QSPI:
#if defined(SL_BOARD_ENABLE_MEMORY_QSPI_PORT)
sl_gpio_set_pin_mode(&enable_memory_qspi_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}
sl_status_t sl_board_disable_memory(sl_board_memory_t memory)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
#if defined(SL_BOARD_ENABLE_MEMORY_SDCARD_PORT)
sl_gpio_t enable_memory_sdcard_gpio = {
.port = SL_BOARD_ENABLE_MEMORY_SDCARD_PORT,
.pin = SL_BOARD_ENABLE_MEMORY_SDCARD_PIN,
};
#endif
#if defined(SL_BOARD_ENABLE_MEMORY_QSPI_PORT)
sl_gpio_t enable_memory_qspi_gpio = {
.port = SL_BOARD_ENABLE_MEMORY_QSPI_PORT,
.pin = SL_BOARD_ENABLE_MEMORY_QSPI_PIN,
};
#endif
switch (memory) {
case SL_BOARD_MEMORY_SDCARD:
#if defined(SL_BOARD_ENABLE_MEMORY_SDCARD_PORT)
sl_gpio_set_pin_mode(&enable_memory_sdcard_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
case SL_BOARD_MEMORY_QSPI:
#if defined(SL_BOARD_ENABLE_MEMORY_QSPI_PORT)
sl_gpio_set_pin_mode(&enable_memory_qspi_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}
sl_status_t sl_board_enable_oscillator(sl_board_oscillator_t oscillator)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
switch (oscillator) {
case SL_BOARD_OSCILLATOR_TCXO:
#if defined(SL_BOARD_ENABLE_OSCILLATOR_TCXO_PORT)
sl_gpio_t enable_oscillator_tcxo_gpio = {
.port = SL_BOARD_ENABLE_OSCILLATOR_TCXO_PORT,
.pin = SL_BOARD_ENABLE_OSCILLATOR_TCXO_PIN,
};
sl_gpio_set_pin_mode(&enable_oscillator_tcxo_gpio, SL_GPIO_MODE_PUSH_PULL, 1);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}
sl_status_t sl_board_disable_oscillator(sl_board_oscillator_t oscillator)
{
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
switch (oscillator) {
case SL_BOARD_OSCILLATOR_TCXO:
#if defined(SL_BOARD_ENABLE_OSCILLATOR_TCXO_PORT)
sl_gpio_t enable_oscillator_tcxo_gpio = {
.port = SL_BOARD_ENABLE_OSCILLATOR_TCXO_PORT,
.pin = SL_BOARD_ENABLE_OSCILLATOR_TCXO_PIN,
};
sl_gpio_set_pin_mode(&enable_oscillator_tcxo_gpio, SL_GPIO_MODE_PUSH_PULL, 0);
status = SL_STATUS_OK;
#else
EFM_ASSERT(false);
#endif
break;
default:
EFM_ASSERT(false); // Should not happen
break;
}
return status;
}

View File

@@ -0,0 +1,98 @@
/***************************************************************************//**
* @file
* @brief Board Init
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_board_control.h"
#include "sl_board_control_config.h"
#include "sl_clock_manager.h"
#if defined(SL_COMPONENT_CATALOG_PRESENT)
#include "sl_component_catalog.h"
#endif
#if defined(SL_CATALOG_MX25_FLASH_SHUTDOWN_USART_PRESENT) || defined(SL_CATALOG_MX25_FLASH_SHUTDOWN_EUSART_PRESENT)
#include "sl_mx25_flash_shutdown.h"
#endif
void sl_board_default_init(void);
void sl_board_init(void)
{
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_GPIO);
// Errata fixes and default pin states
sl_board_default_init();
#if defined(SL_BOARD_ENABLE_SENSOR_RHT) && SL_BOARD_ENABLE_SENSOR_RHT
sl_board_enable_sensor(SL_BOARD_SENSOR_RHT);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_LIGHT) && SL_BOARD_ENABLE_SENSOR_LIGHT
sl_board_enable_sensor(SL_BOARD_SENSOR_LIGHT);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_PRESSURE) && SL_BOARD_ENABLE_SENSOR_PRESSURE
sl_board_enable_sensor(SL_BOARD_SENSOR_PRESSURE);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_HALL) && SL_BOARD_ENABLE_SENSOR_HALL
sl_board_enable_sensor(SL_BOARD_SENSOR_HALL);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_GAS) && SL_BOARD_ENABLE_SENSOR_GAS
sl_board_enable_sensor(SL_BOARD_SENSOR_GAS);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_IMU) && SL_BOARD_ENABLE_SENSOR_IMU
sl_board_enable_sensor(SL_BOARD_SENSOR_IMU);
#endif
#if defined(SL_BOARD_ENABLE_SENSOR_MICROPHONE) && SL_BOARD_ENABLE_SENSOR_MICROPHONE
sl_board_enable_sensor(SL_BOARD_SENSOR_MICROPHONE);
#endif
#if defined(SL_BOARD_ENABLE_DISPLAY) && SL_BOARD_ENABLE_DISPLAY
sl_board_enable_display();
#endif
#if defined(SL_BOARD_ENABLE_MEMORY_SDCARD) && SL_BOARD_ENABLE_MEMORY_SDCARD
sl_board_enable_memory(SL_BOARD_MEMORY_SDCARD);
#endif
#if defined(SL_BOARD_ENABLE_MEMORY_QSPI) && SL_BOARD_ENABLE_MEMORY_QSPI
sl_board_enable_memory(SL_BOARD_MEMORY_QSPI);
#endif
#if (defined(SL_CATALOG_MX25_FLASH_SHUTDOWN_USART_PRESENT) || defined(SL_CATALOG_MX25_FLASH_SHUTDOWN_EUSART_PRESENT)) && \
defined(SL_BOARD_DISABLE_MEMORY_SPI) && SL_BOARD_DISABLE_MEMORY_SPI
sl_mx25_flash_shutdown();
#endif
}
void sl_board_preinit(void)
{
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_GPIO);
#if defined(SL_BOARD_ENABLE_OSCILLATOR_TCXO) && SL_BOARD_ENABLE_OSCILLATOR_TCXO
sl_board_enable_oscillator(SL_BOARD_OSCILLATOR_TCXO);
#endif
}