[core] Add hardware peripheral availability defines
This commit is contained in:
5
cores/beken-7231n/base/lt_defs.h
Normal file
5
cores/beken-7231n/base/lt_defs.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HW_BLE 1
|
||||
5
cores/beken-7231t/base/lt_defs.h
Normal file
5
cores/beken-7231t/base/lt_defs.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HW_BLE 1
|
||||
5
cores/beken-7251/base/lt_defs.h
Normal file
5
cores/beken-7251/base/lt_defs.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HW_BLE 1
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "SerialPrivate.h"
|
||||
|
||||
#if HAS_SERIAL1
|
||||
#if LT_HW_UART1
|
||||
SerialClass Serial1(UART1_PORT);
|
||||
#endif
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
SerialClass Serial2(UART2_PORT);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_ARD_HAS_WIFI 1
|
||||
#define LT_ARD_HAS_SERIAL 1
|
||||
|
||||
#define LT_ARD_HAS_WIFI 1
|
||||
#define LT_ARD_HAS_SERIAL 1
|
||||
#define LT_ARD_MD5_HOSTAPD 1
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HAS_PRINTF 1
|
||||
#define LT_HAS_LWIP 1
|
||||
#define LT_HAS_LWIP2 1
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_MBEDTLS 1
|
||||
#define LT_HAS_FLASH 1
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_LWIP 1
|
||||
#define LT_HAS_LWIP2 1
|
||||
#define LT_HAS_MBEDTLS 1
|
||||
#define LT_HAS_OTA 1
|
||||
#define LT_HAS_PRINTF 1
|
||||
#define LT_HW_DEEP_SLEEP 1
|
||||
#define LT_HW_WATCHDOG 1
|
||||
#define LT_HW_WIFI 1
|
||||
|
||||
#define LT_HEAP_FUNC xPortGetFreeHeapSize
|
||||
#define LT_REALLOC_FUNC pvPortRealloc
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include LT_VARIANT_H
|
||||
#include <lt_pins.h>
|
||||
|
||||
// Choose the main UART output port
|
||||
#ifndef LT_UART_DEFAULT_PORT
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
#define LT_UART_DEFAULT_PORT 2
|
||||
#elif HAS_SERIAL1
|
||||
#elif LT_HW_UART1
|
||||
#define LT_UART_DEFAULT_PORT 1
|
||||
#else
|
||||
#error "No serial port is available"
|
||||
|
||||
@@ -8,31 +8,6 @@
|
||||
|
||||
using namespace arduino;
|
||||
|
||||
#if HAS_SERIAL0
|
||||
#ifndef PIN_SERIAL0_RX
|
||||
#define PIN_SERIAL0_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL0_TX
|
||||
#define PIN_SERIAL0_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_SERIAL1
|
||||
#ifndef PIN_SERIAL1_RX
|
||||
#define PIN_SERIAL1_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL1_TX
|
||||
#define PIN_SERIAL1_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_SERIAL2
|
||||
#ifndef PIN_SERIAL2_RX
|
||||
#define PIN_SERIAL2_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL2_TX
|
||||
#define PIN_SERIAL2_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class SerialClass : public HardwareSerial {
|
||||
private:
|
||||
uint32_t port;
|
||||
|
||||
@@ -44,13 +44,13 @@ using namespace arduino;
|
||||
#include <Serial.h>
|
||||
|
||||
#if HAS_SERIAL_CLASS
|
||||
#if HAS_SERIAL0
|
||||
#if LT_HW_UART0
|
||||
extern SerialClass Serial0;
|
||||
#endif
|
||||
#if HAS_SERIAL1
|
||||
#if LT_HW_UART1
|
||||
extern SerialClass Serial1;
|
||||
#endif
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
extern SerialClass Serial2;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@ extern "C" {
|
||||
#define PIN_UART (1 << 11)
|
||||
|
||||
#define PIN_MODE_ALL 0xFFFFFFFF
|
||||
#define PIN_INVALID 255
|
||||
|
||||
typedef struct PinData_s PinData;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
// APIs
|
||||
#include "lt_api.h" // main API function definitions
|
||||
#include "lt_logger.h" // UART logger utility
|
||||
#include "lt_pins.h" // additional pin macros
|
||||
#include "lt_posix_api.h" // POSIX compat functions
|
||||
// printf silencing methods
|
||||
#include <printf_port.h>
|
||||
|
||||
69
cores/common/base/lt_pins.h
Normal file
69
cores/common/base/lt_pins.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-06-21. */
|
||||
|
||||
#include LT_VARIANT_H
|
||||
|
||||
#define PIN_INVALID 255
|
||||
|
||||
#define LT_HW_UART0 HAS_SERIAL0
|
||||
#define LT_HW_UART1 HAS_SERIAL1
|
||||
#define LT_HW_UART2 HAS_SERIAL2
|
||||
#define LT_HW_I2C0 HAS_WIRE0
|
||||
#define LT_HW_I2C1 HAS_WIRE1
|
||||
#define LT_HW_I2C2 HAS_WIRE2
|
||||
#define LT_HW_SPI0 HAS_SPI0
|
||||
#define LT_HW_SPI1 HAS_SPI1
|
||||
#define LT_HW_SPI2 HAS_SPI2
|
||||
|
||||
#if LT_HW_UART0
|
||||
#ifndef PIN_SERIAL0_RX
|
||||
#define PIN_SERIAL0_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL0_TX
|
||||
#define PIN_SERIAL0_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LT_HW_UART1
|
||||
#ifndef PIN_SERIAL1_RX
|
||||
#define PIN_SERIAL1_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL1_TX
|
||||
#define PIN_SERIAL1_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LT_HW_UART2
|
||||
#ifndef PIN_SERIAL2_RX
|
||||
#define PIN_SERIAL2_RX PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_SERIAL2_TX
|
||||
#define PIN_SERIAL2_TX PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LT_HW_I2C0
|
||||
#ifndef PIN_WIRE0_SDA
|
||||
#define PIN_WIRE0_SDA PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_WIRE0_SCL
|
||||
#define PIN_WIRE0_SCL PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LT_HW_I2C1
|
||||
#ifndef PIN_WIRE1_SDA
|
||||
#define PIN_WIRE1_SDA PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_WIRE1_SCL
|
||||
#define PIN_WIRE1_SCL PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LT_HW_I2C2
|
||||
#ifndef PIN_WIRE2_SDA
|
||||
#define PIN_WIRE2_SDA PIN_INVALID
|
||||
#endif
|
||||
#ifndef PIN_WIRE2_SCL
|
||||
#define PIN_WIRE2_SCL PIN_INVALID
|
||||
#endif
|
||||
#endif
|
||||
@@ -7,7 +7,7 @@ extern "C" {
|
||||
|
||||
osThreadId main_tid = 0;
|
||||
|
||||
#if LT_AUTO_DOWNLOAD_REBOOT && LT_ARD_HAS_SERIAL && defined(PIN_SERIAL2_RX) && defined(PIN_SERIAL2_TX)
|
||||
#if LT_AUTO_DOWNLOAD_REBOOT && LT_ARD_HAS_SERIAL && LT_HW_UART2
|
||||
void lt_init_arduino() {
|
||||
// initialize auto-download-reboot parser
|
||||
Serial2.begin(115200);
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HAS_PRINTF 1
|
||||
#define LT_HAS_FLASH 1
|
||||
#define LT_HW_WATCHDOG 1
|
||||
#define LT_HW_WIFI 1
|
||||
|
||||
#define LT_HEAP_FUNC xPortGetFreeHeapSize
|
||||
#define LT_REALLOC_FUNC pvPortReAlloc
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "SerialPrivate.h"
|
||||
|
||||
#if HAS_SERIAL0
|
||||
#if LT_HW_UART0
|
||||
SerialClass Serial0(0, PIN_SERIAL0_RX, PIN_SERIAL0_TX);
|
||||
#endif
|
||||
#if HAS_SERIAL1
|
||||
#if LT_HW_UART1
|
||||
SerialClass Serial1(1, PIN_SERIAL1_RX, PIN_SERIAL1_TX);
|
||||
#endif
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
SerialClass Serial2(2, PIN_SERIAL2_RX, PIN_SERIAL2_TX);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_ARD_HAS_SERIAL 1
|
||||
|
||||
#define LT_ARD_HAS_SERIAL 1
|
||||
#define LT_ARD_MD5_POLARSSL 1
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_LWIP 1
|
||||
#define LT_HAS_LWIP2 1
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_MBEDTLS 1
|
||||
#define LT_HAS_OTA 1
|
||||
#define LT_HAS_PRINTF 1
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include LT_VARIANT_H
|
||||
#include <lt_pins.h>
|
||||
|
||||
// Choose the main UART output port
|
||||
#ifndef LT_UART_DEFAULT_PORT
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
#define LT_UART_DEFAULT_PORT 2
|
||||
#elif HAS_SERIAL0
|
||||
#elif LT_HW_UART0
|
||||
#define LT_UART_DEFAULT_PORT 0
|
||||
#elif HAS_SERIAL1
|
||||
#elif LT_HW_UART1
|
||||
#define LT_UART_DEFAULT_PORT 1
|
||||
#else
|
||||
#error "No serial port is available"
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "SerialPrivate.h"
|
||||
|
||||
#if HAS_SERIAL0
|
||||
#if LT_HW_UART0
|
||||
SerialClass Serial0(0, PIN_SERIAL0_RX, PIN_SERIAL0_TX);
|
||||
#endif
|
||||
#if HAS_SERIAL1
|
||||
#if LT_HW_UART1
|
||||
SerialClass Serial1(1, PIN_SERIAL1_RX, PIN_SERIAL1_TX);
|
||||
#endif
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
SerialClass Serial2(2, PIN_SERIAL2_RX, PIN_SERIAL2_TX);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_ARD_HAS_SERIAL 1
|
||||
#define LT_ARD_HAS_WIFI 1
|
||||
#define LT_ARD_HAS_SOFTSERIAL 0
|
||||
#define LT_ARD_HAS_WIFI 1
|
||||
#define LT_ARD_HAS_WIRE 0
|
||||
|
||||
#define LT_ARD_MD5_MBEDTLS 1
|
||||
#define LT_ARD_MD5_MBEDTLS 1
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#error "Don't include this file directly"
|
||||
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_LWIP 1
|
||||
#define LT_HAS_LWIP2 1
|
||||
#define LT_HAS_FREERTOS 1
|
||||
#define LT_HAS_MBEDTLS 1
|
||||
#define LT_HAS_PRINTF 1
|
||||
#define LT_HW_BLE 1
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include LT_VARIANT_H
|
||||
#include <lt_pins.h>
|
||||
|
||||
// Choose the main UART output port
|
||||
#ifndef LT_UART_DEFAULT_PORT
|
||||
#if HAS_SERIAL2
|
||||
#if LT_HW_UART2
|
||||
#define LT_UART_DEFAULT_PORT 2
|
||||
#elif HAS_SERIAL0
|
||||
#elif LT_HW_UART0
|
||||
#define LT_UART_DEFAULT_PORT 0
|
||||
#elif HAS_SERIAL1
|
||||
#elif LT_HW_UART1
|
||||
#define LT_UART_DEFAULT_PORT 1
|
||||
#else
|
||||
#error "No serial port is available"
|
||||
|
||||
Reference in New Issue
Block a user