Skip to content

Commit

Permalink
Merge branch 'esp-idf-5' into 'master'
Browse files Browse the repository at this point in the history
Esp idf 5

See merge request embedded/general-support-library!44
  • Loading branch information
gdex committed Mar 16, 2024
2 parents a3d2cdf + 5d6f363 commit 88d9209
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ else ()
set(includedirs
${CMAKE_CURRENT_LIST_DIR}
)
set(private_requirements)
if (IDF_VERSION_MAJOR GREATER 4)
list(APPEND private_requirements esp_adc driver esp_timer)
endif ()
idf_component_register(INCLUDE_DIRS ${includedirs}
SRCS ${srcs}
PRIV_REQUIRES ${private_requirements}
)
set_source_files_properties(graphics/EmbeddedFonts.cpp PROPERTIES COMPILE_FLAGS -Wno-missing-braces)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
Expand Down
8 changes: 6 additions & 2 deletions esp32-esp-idf/AnalogPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int singleReadADC1(int8_t channel)
{
int result = -1;
adc1_config_width(ADC_WIDTH_BIT_12);
if (adc1_config_channel_atten((adc1_channel_t)channel, ADC_ATTEN_11db) == ESP_OK)
if (adc1_config_channel_atten((adc1_channel_t)channel, ADC_ATTEN_DB_12) == ESP_OK)
{
result = adc1_get_raw((adc1_channel_t)channel);
}
Expand All @@ -41,7 +41,7 @@ int singleReadADC1(int8_t channel)
int singleReadADC2(int8_t channel)
{
int result = -1;
if (adc2_config_channel_atten((adc2_channel_t)channel, ADC_ATTEN_11db) == ESP_OK)
if (adc2_config_channel_atten((adc2_channel_t)channel, ADC_ATTEN_DB_12) == ESP_OK)
{
adc2_get_raw((adc2_channel_t)channel, ADC_WIDTH_BIT_12, &result);
}
Expand All @@ -53,7 +53,9 @@ int embedded::AnalogPin::singleRead() const
{
auto [adc, channel] = digitalPinToAnalogChannel(gpioPin.pin);
int result = -1;
#if __GCC_VERSION__ < 90000
adc_power_acquire();
#endif
switch (adc)
{
case 0:
Expand All @@ -65,6 +67,8 @@ int embedded::AnalogPin::singleRead() const
default:
break;
};
#if __GCC_VERSION__ < 90000
adc_power_release();
#endif
return result;
}
1 change: 1 addition & 0 deletions esp32-esp-idf/Delays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/portmacro.h>
#include <esp_timer.h>

void embedded::delay(uint32_t milliseconds)
{
Expand Down
5 changes: 5 additions & 0 deletions esp32-esp-idf/GpioDigitalPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

#include "GpioPinDefinition.h"

#if __GCC_VERSION__ >= 90000
#include <soc/gpio_num.h>
#include <esp_clock_output.h>
#else
#include <driver/gpio.h>
#endif

namespace embedded
{
Expand Down
3 changes: 2 additions & 1 deletion esp32-esp-idf/I2CBus.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include <hal/i2c_types.h>

namespace embedded
{
Expand All @@ -11,7 +12,7 @@ struct I2CBus
bool init(int sdaPin, int sclPin, uint32_t frequency, bool pullupSda = true, bool pullupScl = true) const;
void resetBus() const;

int bus;
i2c_port_t bus;
};

}
1 change: 1 addition & 0 deletions esp32-esp-idf/I2CDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../I2CDevice.h"
#include "I2CBus.h"

#include <freertos/FreeRTOS.h>
#include <driver/i2c.h>

bool embedded::I2CDevice::sendSync(const uint8_t *data, uint16_t count) const
Expand Down
1 change: 1 addition & 0 deletions esp32-esp-idf/SimpleUartDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SimpleUartDevice.h"
#include <hal/uart_types.h>
#include <driver/uart.h>

namespace embedded
Expand Down
3 changes: 2 additions & 1 deletion esp32-esp-idf/SimpleUartDevice.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include <hal/uart_types.h>

namespace embedded
{
Expand Down Expand Up @@ -42,7 +43,7 @@ class SimpleUartDevice
int receiveBlocking(uint8_t* data, std::size_t size, uint32_t timeoutMilliseconds = 20) const;

private:
int uartNum;
uart_port_t uartNum;
};

} // embedded
1 change: 1 addition & 0 deletions esp32-esp-idf/SpiBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "GpioPinDefinition.h"

#include <soc/lldesc.h>
#include <driver/spi_master.h>
#include <algorithm>

Expand Down

0 comments on commit 88d9209

Please sign in to comment.