Compare commits
43 Commits
659542f094
...
8304828bf3
| Author | SHA1 | Date | |
|---|---|---|---|
| 8304828bf3 | |||
| 65f450a0e0 | |||
| bf62c9670d | |||
| 80d94bd343 | |||
| 7cff447732 | |||
| 2779b867cc | |||
| b5c27e5cb4 | |||
| e04474bb83 | |||
| c4bb4b048c | |||
| 058cad7ca0 | |||
| 4625f56c6e | |||
| f57868b3fd | |||
| 640ce09132 | |||
| 166963288b | |||
| c8a8816bd9 | |||
| 19aac5fbdb | |||
| 73e1535d14 | |||
| b50900a826 | |||
| d3bf7ff7c5 | |||
| fad1980f98 | |||
| 9c6fa9d152 | |||
| 320a756799 | |||
| d876d70cd4 | |||
| 2a55eb34ab | |||
| 933ce93fb1 | |||
| e2db52c0dc | |||
| 5eb3dbcd9f | |||
| 4ac4507538 | |||
| 98c9fb7201 | |||
| c705359427 | |||
| e1d89282ef | |||
| 24e33368b2 | |||
| 04edfa7c99 | |||
| 9f05bcf066 | |||
| 1ab7c4ce9a | |||
| 179e44ec60 | |||
| dde5b09581 | |||
| 985aa056d0 | |||
|
|
dcf28d0868 | ||
|
|
9cc58099b4 | ||
|
|
1216862aec | ||
|
|
7ad0a3cb04 | ||
|
|
bab3eb19bc |
@ -17,7 +17,7 @@ class HelloWorldApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest hello_world_app = {
|
||||
.id = "HelloWorld",
|
||||
.name = "Hello World",
|
||||
.appId = "HelloWorld",
|
||||
.appName = "Hello World",
|
||||
.createApp = create<HelloWorldApp>
|
||||
};
|
||||
|
||||
@ -20,4 +20,9 @@ dependencies:
|
||||
version: "1.7.6~1"
|
||||
rules:
|
||||
- if: "target == esp32s3"
|
||||
jgromes/radiolib:
|
||||
version: "7.2.1"
|
||||
rules:
|
||||
- if: "target in [esp32s3, esp32p4]"
|
||||
|
||||
idf: '5.5'
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include "CYD4848S040C.h"
|
||||
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
#include "devices/St7701Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
|
||||
@ -12,7 +15,7 @@ static bool initBoot() {
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
std::reinterpret_pointer_cast<Device>(std::make_shared<St7701Display>()),
|
||||
std::make_shared<St7701Display>(),
|
||||
createSdCard()
|
||||
};
|
||||
}
|
||||
@ -59,7 +62,7 @@ const Configuration cyd_4848s040c_config = {
|
||||
}
|
||||
},
|
||||
.spi {
|
||||
//SD Card
|
||||
// SD Card & display init
|
||||
spi::Configuration {
|
||||
.device = SPI2_HOST,
|
||||
.dma = SPI_DMA_CH_AUTO,
|
||||
@ -68,20 +71,20 @@ const Configuration cyd_4848s040c_config = {
|
||||
.miso_io_num = GPIO_NUM_41,
|
||||
.sclk_io_num = GPIO_NUM_48,
|
||||
.quadwp_io_num = -1,
|
||||
.quadhd_io_num = -1,
|
||||
.quadhd_io_num = GPIO_NUM_42,
|
||||
.data4_io_num = -1,
|
||||
.data5_io_num = -1,
|
||||
.data6_io_num = -1,
|
||||
.data7_io_num = -1,
|
||||
.data_io_default_level = false,
|
||||
.max_transfer_sz = 8192,
|
||||
.max_transfer_sz = 1024 * 128,
|
||||
.flags = 0,
|
||||
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
|
||||
.intr_flags = 0
|
||||
},
|
||||
.initMode = spi::InitMode::ByTactility,
|
||||
.isMutable = false,
|
||||
.lock = nullptr
|
||||
.lock = tt::lvgl::getSyncLock()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,7 +11,9 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getSyncLock(),
|
||||
std::vector { GPIO_NUM_39 }
|
||||
);
|
||||
|
||||
auto sdcard = std::make_shared<SpiSdCardDevice>(
|
||||
|
||||
@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lcd ST7796 BQ25896 BQ27220 TCA8418 DRV2605 PwmBacklight driver esp_adc
|
||||
REQUIRES Tactility esp_lcd ST7796 BQ25896 BQ27220 TCA8418 DRV2605 SX126x PwmBacklight driver esp_adc
|
||||
)
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include <Bq25896.h>
|
||||
#include <Drv2605.h>
|
||||
#include <Sx1262.h>
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
#define TPAGER_SPI_TRANSFER_SIZE_LIMIT (480 * 222 * (LV_COLOR_DEPTH / 8))
|
||||
@ -22,6 +23,17 @@ static DeviceVector createDevices() {
|
||||
auto tca8418 = std::make_shared<Tca8418>(I2C_NUM_0);
|
||||
auto keyboard = std::make_shared<TpagerKeyboard>(tca8418);
|
||||
|
||||
auto sx1262 = std::make_shared<Sx1262>(Sx1262::Configuration{
|
||||
.spiHostDevice = SPI2_HOST,
|
||||
.spiFrequency = 10'000'000,
|
||||
.csPin = GPIO_NUM_36,
|
||||
.resetPin = GPIO_NUM_47,
|
||||
.busyPin = GPIO_NUM_48,
|
||||
.irqPin = GPIO_NUM_14,
|
||||
.tcxoVoltage = 3.0,
|
||||
.useRegulatorLdo = false
|
||||
});
|
||||
|
||||
return std::vector<std::shared_ptr<Device>> {
|
||||
tca8418,
|
||||
std::make_shared<Bq25896>(I2C_NUM_0),
|
||||
@ -31,7 +43,8 @@ static DeviceVector createDevices() {
|
||||
createTpagerSdCard(),
|
||||
createDisplay(),
|
||||
keyboard,
|
||||
std::make_shared<TpagerEncoder>()
|
||||
std::make_shared<TpagerEncoder>(),
|
||||
sx1262
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "TpagerEncoder.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/hal/Gpio.h>
|
||||
#include <driver/gpio.h>
|
||||
|
||||
constexpr auto* TAG = "TpagerEncoder";
|
||||
constexpr auto ENCODER_A = GPIO_NUM_40;
|
||||
|
||||
@ -11,7 +11,7 @@ std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
|
||||
240,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
GPIO_NUM_13,
|
||||
GPIO_NUM_5
|
||||
);
|
||||
|
||||
@ -1,39 +1,32 @@
|
||||
# Contributing
|
||||
|
||||
## Accepted changes
|
||||
## New features and boards
|
||||
|
||||
Before releasing version 1.0.0, the APIs are changing rapidly.
|
||||
I want to minimize the amount of changes that I have to maintain, because it limits the amount of breaking changes that I have to deal with when the APIs change.
|
||||
Feel free to open an [issue](https://github.com/ByteWelder/Tactility/issues/new)
|
||||
to discuss ideas you have regarding the implementation of new boards or features.
|
||||
|
||||
### New features
|
||||
Keep in mind that the internal APIs are changing rapidly. They might change considerably in a short timespan.
|
||||
This means it's likely that you get merge conflicts while developing new features or boards.
|
||||
|
||||
These are currently not accepted.
|
||||
## Fixing things
|
||||
|
||||
### Visual / interaction design changes
|
||||
|
||||
These are currently not accepted. I'm aware that there is a lot of room for improvement, but I want to mainly focusing on strong technical foundations before
|
||||
I start building further on top of that.
|
||||
Feel free to open an [issue](https://github.com/ByteWelder/Tactility/issues/new) to discuss ideas you have, if you feel like they will have a considerable impact.
|
||||
|
||||
### Fixing things
|
||||
|
||||
The general take here is that minor changes are not accepted at this stage. I don't want to spend my time reviewing and discussing these during the current stage of the project.
|
||||
The general take here is that minor changes are not accepted at this stage.
|
||||
I don't want to spend my time reviewing and discussing these during the current stage of the project.
|
||||
|
||||
Only fixes for serious issues are accepted, like:
|
||||
|
||||
- Bugs
|
||||
- Crashes
|
||||
- Security issues
|
||||
|
||||
Some examples of non-serious issues include:
|
||||
- Documentation changes
|
||||
|
||||
- Code documentation changes
|
||||
- Renaming code
|
||||
- Fixes for compiler warnings that have low impact on the actual application logic (e.g. only happens on simulator when calling a logging function)
|
||||
- Typographical errors
|
||||
- Fixes for compiler warnings that have a low impact on the actual application logic (e.g. only happens on simulator when calling a logging function)
|
||||
|
||||
### New board implementations
|
||||
|
||||
Please open an [issue](https://github.com/ByteWelder/Tactility/issues/new) on GitHub to discuss new boards.
|
||||
|
||||
### Anything that doesn't fall in the above categories?
|
||||
## Anything that doesn't fall in the above categories?
|
||||
|
||||
Please [contact me](https://tactility.one/#/support) first!
|
||||
|
||||
@ -42,6 +35,13 @@ Please [contact me](https://tactility.one/#/support) first!
|
||||
Pull requests should only contain a single set of changes that are related to each other.
|
||||
That way, an approved set of changes will not be blocked by an unapproved set of changes.
|
||||
|
||||
## Licensing
|
||||
|
||||
All contributions to a Tactility (sub)project will be licensed under the license(s) of that project.
|
||||
|
||||
When third party code is used, its license must be included.
|
||||
It's important that these third-party licenses are compatible with the relevant Tactility (sub)projects.
|
||||
|
||||
## Code Style
|
||||
|
||||
See [this document](CODING_STYLE.md) and [.clang-format](.clang-format).
|
||||
|
||||
|
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 528 B |
|
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 144 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 146 B |
|
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 146 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
|
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 524 B |
|
Before Width: | Height: | Size: 517 B After Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 534 B After Width: | Height: | Size: 534 B |
@ -15,9 +15,20 @@
|
||||
Write the user choice to a file on the card.
|
||||
File contains 3 statuses: ignore, data, .. initdata?
|
||||
The latter is used for auto-selecting it as data partition.
|
||||
- Support direct installation of an `.app` file with `tactility.py install helloworld.app <ip>`
|
||||
- Support `tactility.py target <ip>` to remember the device IP address.
|
||||
- External app error code 22 should warn that the user might've forgotten a `main()` entry point
|
||||
- Bug: `Buildscript/release-sdk-current.sh` should delete the currently released SDK. It should probably also output it with versioning and target platform naming so it can be referred to as if it is a real release.
|
||||
- Tactility docs: external app dev guide should explain [debugging](https://docs.zephyrproject.org/latest/services/llext/debug.html)
|
||||
- elf_loader changes/suggestions:
|
||||
- Make entry-point optional (so we can build libraries, or have the `manifest` as a global symbol)
|
||||
- Implement support for alternative symbol lists. e.g. a function pointer that resolves a single symbol.
|
||||
- Implement the entire list of [soft-float library functions](https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html) to `tt_init.cpp`
|
||||
- `tactility.py` should stop running applications when it is: uninstalling, installing, or running an application that is already running.
|
||||
|
||||
## Medium Priority
|
||||
|
||||
- TactilityTool: Make API compatibility table (and check for compatibility in the tool itself)
|
||||
- Improve EspLcdDisplay to contain all the standard configuration options, and implement a default init function. Add a configuration class.
|
||||
- Statusbar icon that shows low/critical memory warnings
|
||||
- Make WiFi setup app that starts an access point and hosts a webpage to set up the device.
|
||||
@ -28,6 +39,7 @@
|
||||
- Bug: Turn on WiFi (when testing it wasn't connected/connecting - just active). Open chat. Observe crash.
|
||||
- Bug: Crash handling app cannot be exited with an EncoderDevice. (current work-around is to manually reset the device)
|
||||
- I2C app should show error when I2C port is disabled when the scan button was manually pressed
|
||||
- TactilitySDK: Support automatic scanning of header files so that we can generate the `tt_init.cpp` symbols list.
|
||||
|
||||
## Lower Priority
|
||||
|
||||
@ -93,6 +105,7 @@
|
||||
- RSS reader
|
||||
- Static file web server (with option to specify path and port)
|
||||
- Diceware
|
||||
- Port TamaFi https://github.com/cifertech/TamaFi
|
||||
|
||||
# App Store
|
||||
|
||||
|
||||
5
Drivers/RadioLibCompat/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility radiolib
|
||||
)
|
||||
3
Drivers/RadioLibCompat/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# RadioLibCompat
|
||||
|
||||
A set of helper classes to implement `RadioLib` drivers in Tactility.
|
||||
167
Drivers/RadioLibCompat/Source/RadiolibTactilityHal.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
#include "RadiolibTactilityHal.h"
|
||||
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
constexpr const char* TAG = "RadiolibTactilityHal";
|
||||
|
||||
void RadiolibTactilityHal::init() {
|
||||
// we only need to init the SPI here
|
||||
spiBegin();
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::term() {
|
||||
// we only need to stop the SPI here
|
||||
spiEnd();
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::pinMode(uint32_t pin, uint32_t mode) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_hal_context_t gpiohal;
|
||||
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
|
||||
|
||||
gpio_config_t conf = {
|
||||
.pin_bit_mask = (1ULL<<pin),
|
||||
.mode = (gpio_mode_t)mode,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.intr_type = (gpio_int_type_t)gpiohal.dev->pin[pin].int_type,
|
||||
};
|
||||
gpio_config(&conf);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::digitalWrite(uint32_t pin, uint32_t value) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_set_level((gpio_num_t)pin, value);
|
||||
}
|
||||
|
||||
uint32_t RadiolibTactilityHal::digitalRead(uint32_t pin) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(gpio_get_level((gpio_num_t)pin));
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) {
|
||||
if(interruptNum == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isrServiceInitialized) {
|
||||
gpio_install_isr_service((int)ESP_INTR_FLAG_IRAM);
|
||||
isrServiceInitialized = true;
|
||||
}
|
||||
gpio_set_intr_type((gpio_num_t)interruptNum, (gpio_int_type_t)(mode & 0x7));
|
||||
|
||||
// this uses function typecasting, which is not defined when the functions have different signatures
|
||||
// untested and might not work
|
||||
// TODO: I think the wisest course of action is forbidding registration via RadioLib entirely,
|
||||
// as it doesn't suit Tactility with its lack of context passing
|
||||
gpio_isr_handler_add((gpio_num_t)interruptNum, (void (*)(void*))interruptCb, NULL);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::detachInterrupt(uint32_t interruptNum) {
|
||||
if(interruptNum == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_isr_handler_remove((gpio_num_t)interruptNum);
|
||||
gpio_wakeup_disable((gpio_num_t)interruptNum);
|
||||
gpio_set_intr_type((gpio_num_t)interruptNum, GPIO_INTR_DISABLE);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::delay(unsigned long ms) {
|
||||
vTaskDelay(ms / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::delayMicroseconds(unsigned long us) {
|
||||
uint64_t m = (uint64_t)esp_timer_get_time();
|
||||
if(us) {
|
||||
uint64_t e = (m + us);
|
||||
if(m > e) { // overflow
|
||||
while((uint64_t)esp_timer_get_time() > e);
|
||||
}
|
||||
while((uint64_t)esp_timer_get_time() < e);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long RadiolibTactilityHal::millis() {
|
||||
return((unsigned long)(esp_timer_get_time() / 1000ULL));
|
||||
}
|
||||
|
||||
unsigned long RadiolibTactilityHal::micros() {
|
||||
return((unsigned long)(esp_timer_get_time()));
|
||||
}
|
||||
|
||||
long RadiolibTactilityHal::pulseIn(uint32_t pin, uint32_t state, unsigned long timeout) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
this->pinMode(pin, GPIO_MODE_INPUT);
|
||||
uint32_t start = this->micros();
|
||||
uint32_t curtick = this->micros();
|
||||
|
||||
while(this->digitalRead(pin) == state) {
|
||||
if((this->micros() - curtick) > timeout) {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
return(this->micros() - start);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::spiBegin() {
|
||||
if (!spiInitialized) {
|
||||
TT_LOG_I(TAG, "SPI Begin!");
|
||||
spi_device_interface_config_t devcfg = {};
|
||||
devcfg.clock_speed_hz = spiFrequency;
|
||||
devcfg.mode = 0;
|
||||
devcfg.spics_io_num = csPin;
|
||||
devcfg.queue_size = 1;
|
||||
esp_err_t ret = spi_bus_add_device(spiHostDevice, &devcfg, &spiDeviceHandle);
|
||||
if (ret != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to add SPI device: %s", esp_err_to_name(ret));
|
||||
}
|
||||
spiInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::spiBeginTransaction() {
|
||||
// This function is used to set up the transaction (speed, bit order, mode, ...).
|
||||
// With the ESP-IDF HAL this is automatically done, so no code needed.
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
|
||||
spi_transaction_t t;
|
||||
|
||||
auto lock = getLock()->asScopedLock();
|
||||
bool locked = lock.lock(portMAX_DELAY);
|
||||
if (!locked) {
|
||||
TT_LOG_E(TAG, "Failed to aquire SPI lock");
|
||||
}
|
||||
|
||||
memset(&t, 0, sizeof(t)); // Zero out the transaction
|
||||
t.length = len * 8; // Length is in bits
|
||||
t.tx_buffer = out; // The data to send
|
||||
t.rx_buffer = in; // The data to receive
|
||||
spi_device_polling_transmit(spiDeviceHandle, &t);
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::spiEndTransaction() {
|
||||
// nothing needs to be done here
|
||||
}
|
||||
|
||||
void RadiolibTactilityHal::spiEnd() {
|
||||
if (spiInitialized) {
|
||||
spi_bus_remove_device(spiDeviceHandle);
|
||||
spiInitialized = false;
|
||||
}
|
||||
}
|
||||
64
Drivers/RadioLibCompat/Source/RadiolibTactilityHal.h
Normal file
@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Lock.h>
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/spi_master.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RadiolibTactilityHal : public RadioLibHal {
|
||||
private:
|
||||
spi_host_device_t spiHostDevice;
|
||||
int spiFrequency;
|
||||
gpio_num_t csPin;
|
||||
spi_device_handle_t spiDeviceHandle;
|
||||
std::shared_ptr<tt::Lock> lock;
|
||||
bool spiInitialized;
|
||||
bool isrServiceInitialized;
|
||||
|
||||
public:
|
||||
explicit RadiolibTactilityHal(spi_host_device_t spiHostDevice, int spiFrequency, gpio_num_t csPin)
|
||||
: RadioLibHal(
|
||||
GPIO_MODE_INPUT,
|
||||
GPIO_MODE_OUTPUT,
|
||||
0, // LOW
|
||||
1, // HIGH
|
||||
GPIO_INTR_POSEDGE,
|
||||
GPIO_INTR_NEGEDGE)
|
||||
, spiHostDevice(spiHostDevice)
|
||||
, spiFrequency(spiFrequency)
|
||||
, csPin(csPin)
|
||||
, lock(tt::hal::spi::getLock(spiHostDevice))
|
||||
, spiInitialized(false)
|
||||
, isrServiceInitialized(false) {}
|
||||
|
||||
void init() override;
|
||||
void term() override;
|
||||
|
||||
void pinMode(uint32_t pin, uint32_t mode) override;
|
||||
void digitalWrite(uint32_t pin, uint32_t value) override;
|
||||
uint32_t digitalRead(uint32_t pin) override;
|
||||
void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) override;
|
||||
void detachInterrupt(uint32_t interruptNum) override;
|
||||
|
||||
void delay(unsigned long ms) override;
|
||||
void delayMicroseconds(unsigned long us) override;
|
||||
unsigned long millis() override;
|
||||
unsigned long micros() override;
|
||||
long pulseIn(uint32_t pin, uint32_t state, unsigned long timeout) override;
|
||||
|
||||
void spiBegin() override;
|
||||
void spiBeginTransaction() override;
|
||||
void spiTransfer(uint8_t* out, size_t len, uint8_t* in) override;
|
||||
void spiEndTransaction() override;
|
||||
void spiEnd();
|
||||
|
||||
std::shared_ptr<tt::Lock> getLock() const { return lock; }
|
||||
};
|
||||
93
Drivers/RadioLibCompat/Source/RadiolibThreadedDevice.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "RadiolibThreadedDevice.h"
|
||||
#include <cstring>
|
||||
|
||||
constexpr const char* TAG = "RadiolibThreadedDevice";
|
||||
|
||||
bool RadiolibThreadedDevice::start() {
|
||||
auto lock = getMutex().asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
if ((thread != nullptr) && (thread->getState() != tt::Thread::State::Stopped)) {
|
||||
TT_LOG_W(TAG, "Already started");
|
||||
return true;
|
||||
}
|
||||
|
||||
threadInterrupted = false;
|
||||
|
||||
TT_LOG_I(TAG, "Starting thread");
|
||||
setState(State::PendingOn);
|
||||
|
||||
thread = std::make_unique<tt::Thread>(
|
||||
threadName,
|
||||
threadSize,
|
||||
[this]() {
|
||||
return this->threadMain();
|
||||
}
|
||||
);
|
||||
thread->setPriority(tt::Thread::Priority::High);
|
||||
thread->start();
|
||||
|
||||
TT_LOG_I(TAG, "Starting finished");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RadiolibThreadedDevice::stop() {
|
||||
auto lock = getMutex().asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
setState(State::PendingOff);
|
||||
|
||||
if (thread != nullptr) {
|
||||
threadInterrupted = true;
|
||||
interruptSignal();
|
||||
|
||||
// Detach thread, it will auto-delete when leaving the current scope
|
||||
auto old_thread = std::move(thread);
|
||||
|
||||
if (old_thread->getState() != tt::Thread::State::Stopped) {
|
||||
// Unlock so thread can lock
|
||||
lock.unlock();
|
||||
// Wait for thread to finish
|
||||
old_thread->join();
|
||||
// Re-lock to continue logic below
|
||||
lock.lock();
|
||||
}
|
||||
}
|
||||
|
||||
setState(State::Off);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RadiolibThreadedDevice::isThreadInterrupted() const {
|
||||
auto lock = getMutex().asScopedLock();
|
||||
lock.lock();
|
||||
return threadInterrupted;
|
||||
}
|
||||
|
||||
int32_t RadiolibThreadedDevice::threadMain() {
|
||||
|
||||
int rc = doBegin(getModulation());
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
setState(State::On);
|
||||
|
||||
while (!isThreadInterrupted()) {
|
||||
doListen();
|
||||
|
||||
// Thread might've been interrupted in the meanwhile
|
||||
if (isThreadInterrupted()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (getTxQueueSize() > 0) {
|
||||
doTransmit();
|
||||
} else {
|
||||
doReceive();
|
||||
}
|
||||
}
|
||||
|
||||
doEnd();
|
||||
return 0;
|
||||
}
|
||||
36
Drivers/RadioLibCompat/Source/RadiolibThreadedDevice.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/radio/RadioDevice.h>
|
||||
#include <Tactility/Thread.h>
|
||||
|
||||
class RadiolibThreadedDevice : public tt::hal::radio::RadioDevice {
|
||||
|
||||
private:
|
||||
std::string threadName;
|
||||
size_t threadSize;
|
||||
std::unique_ptr<tt::Thread> _Nullable thread;
|
||||
bool threadInterrupted = false;
|
||||
|
||||
protected:
|
||||
virtual int32_t threadMain();
|
||||
bool isThreadInterrupted() const;
|
||||
|
||||
virtual void interruptSignal() = 0;
|
||||
|
||||
virtual int doBegin(const Modulation modulation) = 0;
|
||||
virtual void doEnd() = 0;
|
||||
virtual void doTransmit() = 0;
|
||||
virtual void doListen() = 0;
|
||||
virtual void doReceive() = 0;
|
||||
|
||||
public:
|
||||
explicit RadiolibThreadedDevice(const std::string& threadName, const size_t threadSize)
|
||||
: threadName(threadName)
|
||||
, threadSize(threadSize)
|
||||
{}
|
||||
|
||||
~RadiolibThreadedDevice() override = default;
|
||||
|
||||
virtual bool start() override;
|
||||
virtual bool stop() override;
|
||||
};
|
||||
5
Drivers/SX126x/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility driver RadioLibCompat radiolib
|
||||
)
|
||||
7
Drivers/SX126x/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# SX126x
|
||||
|
||||
Radio with LoRa/(G)FSK capabilities.
|
||||
|
||||
## SX1262
|
||||
|
||||
- [Product Information](https://www.semtech.com/products/wireless-rf/lora-connect/sx1262)
|
||||
441
Drivers/SX126x/Source/Sx1262.cpp
Normal file
@ -0,0 +1,441 @@
|
||||
#include "Sx1262.h"
|
||||
|
||||
#include <cstring>
|
||||
#include "hal/gpio_hal.h"
|
||||
|
||||
constexpr const char* TAG = "Sx1262";
|
||||
|
||||
template<typename T>
|
||||
static constexpr Sx1262::ParameterStatus checkLimitsAndApply(T &target, const float value, const float lower, const float upper, const unsigned step = 0) {
|
||||
if ((value >= lower) && (value <= upper)) {
|
||||
if (step != 0) {
|
||||
int ivalue = static_cast<int>(value);
|
||||
if ((ivalue % step) != 0) {
|
||||
return Sx1262::ParameterStatus::ValueError;
|
||||
}
|
||||
}
|
||||
|
||||
target = static_cast<T>(value);
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
}
|
||||
return Sx1262::ParameterStatus::ValueError;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static constexpr Sx1262::ParameterStatus checkValuesAndApply(T &target, const float value, std::initializer_list<float> valids) {
|
||||
for (float valid : valids) {
|
||||
if (value == valid) {
|
||||
target = static_cast<T>(value);
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
}
|
||||
}
|
||||
return Sx1262::ParameterStatus::ValueError;
|
||||
}
|
||||
|
||||
void IRAM_ATTR dio1handler(void* context) {
|
||||
((Sx1262*)context)->dio1Event();
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::setLoraParameter(const Parameter parameter, const float value) {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
return checkLimitsAndApply(power, value, -9.0, 22.0);
|
||||
case Frequency:
|
||||
return checkLimitsAndApply(frequency, value, 150.0, 960.0);
|
||||
case Bandwidth:
|
||||
return checkValuesAndApply(bandwidth, value, {
|
||||
7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125.0, 250.0, 500.0
|
||||
});
|
||||
case SpreadFactor:
|
||||
return checkLimitsAndApply(spreadFactor, value, 7.0, 12.0, 1);
|
||||
case CodingRate:
|
||||
return checkLimitsAndApply(codingRate, value, 5.0, 8.0, 1);
|
||||
case SyncWord:
|
||||
return checkLimitsAndApply(syncWord, value, 0.0, 255.0, 1);
|
||||
case PreambleLength:
|
||||
return checkLimitsAndApply(preambleLength, value, 0.0, 65535.0, 1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TT_LOG_W(TAG, "Tried to set unsupported LoRa parameter \"%s\" to %f", toString(parameter), value);
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::setFskParameter(const Parameter parameter, const float value) {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
return checkLimitsAndApply(power, value, -9.0, 22.0);
|
||||
case Frequency:
|
||||
return checkLimitsAndApply(frequency, value, 150.0, 960.0);
|
||||
case Bandwidth:
|
||||
return checkValuesAndApply(bandwidth, value, {
|
||||
4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, 78.2
|
||||
});
|
||||
case PreambleLength:
|
||||
return checkLimitsAndApply(preambleLength, value, 0.0, 65535.0, 1);
|
||||
case DataRate:
|
||||
return checkLimitsAndApply(bitRate, value, 0.6, 300.0);
|
||||
case FrequencyDeviation:
|
||||
return checkLimitsAndApply(frequencyDeviation, value, 0.0, 200.0);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TT_LOG_W(TAG, "Tried to set unsupported FSK parameter \"%s\" to %f", toString(parameter), value);
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::setLrFhssParameter(const Parameter parameter, const float value) {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
return checkLimitsAndApply(power, value, -9.0, 22.0);
|
||||
case Bandwidth:
|
||||
return checkValuesAndApply(bandwidth, value, {
|
||||
39.06, 85.94, 136.72, 183.59, 335.94, 386.72, 722.66, 773.44, 1523.4, 1574.2
|
||||
});
|
||||
case CodingRate:
|
||||
return checkValuesAndApply(codingRate, value, {
|
||||
RADIOLIB_SX126X_LR_FHSS_CR_5_6,
|
||||
RADIOLIB_SX126X_LR_FHSS_CR_2_3,
|
||||
RADIOLIB_SX126X_LR_FHSS_CR_1_2,
|
||||
RADIOLIB_SX126X_LR_FHSS_CR_1_3
|
||||
});
|
||||
case NarrowGrid:
|
||||
return checkLimitsAndApply(narrowGrid, value, 0.0, 1.0, 1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TT_LOG_W(TAG, "Tried to set unsupported LR-FHSS parameter \"%s\" to %f", toString(parameter), value);
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::setParameter(const Parameter parameter, const float value) {
|
||||
const auto currentModulation = getModulation();
|
||||
|
||||
switch (currentModulation) {
|
||||
case Modulation::LoRa:
|
||||
return setLoraParameter(parameter, value);
|
||||
case Modulation::Fsk:
|
||||
return setFskParameter(parameter, value);
|
||||
case Modulation::LrFhss:
|
||||
return setLrFhssParameter(parameter, value);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Shouldn't be reachable, return failsafe value
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::getLoraParameter(const Parameter parameter, float &value) const {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
value = power;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case Frequency:
|
||||
value = frequency;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case Bandwidth:
|
||||
value = bandwidth;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case SpreadFactor:
|
||||
value = spreadFactor;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case CodingRate:
|
||||
value = codingRate;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case SyncWord:
|
||||
value = syncWord;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case PreambleLength:
|
||||
value = preambleLength;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::getFskParameter(const Parameter parameter, float &value) const {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
value = power;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case Frequency:
|
||||
value = frequency;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case Bandwidth:
|
||||
value = bandwidth;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case DataRate:
|
||||
value = bitRate;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case FrequencyDeviation:
|
||||
value = frequencyDeviation;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::getLrFhssParameter(const Parameter parameter, float &value) const {
|
||||
using enum Parameter;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
value = power;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case Bandwidth:
|
||||
value = bandwidth;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case CodingRate:
|
||||
value = codingRate;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
case NarrowGrid:
|
||||
value = narrowGrid;
|
||||
return Sx1262::ParameterStatus::Success;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
|
||||
Sx1262::ParameterStatus Sx1262::getParameter(const Parameter parameter, float &value) const {
|
||||
const auto currentModulation = getModulation();
|
||||
|
||||
// No warnings are emitted to be able to discover parameters by return status
|
||||
switch (currentModulation) {
|
||||
case Modulation::LoRa:
|
||||
return getLoraParameter(parameter, value);
|
||||
case Modulation::Fsk:
|
||||
return getFskParameter(parameter, value);
|
||||
case Modulation::LrFhss:
|
||||
return getLrFhssParameter(parameter, value);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Shouldn't be reachable, return failsafe value
|
||||
return Sx1262::ParameterStatus::Unavailable;
|
||||
}
|
||||
|
||||
tt::hal::radio::Unit Sx1262::getParameterUnit(const Parameter parameter) const {
|
||||
using enum Parameter;
|
||||
using Unit = tt::hal::radio::Unit;
|
||||
|
||||
switch (parameter) {
|
||||
case Power:
|
||||
return Unit(Unit::Name::DecibelMilliwatts);
|
||||
case Frequency:
|
||||
return Unit(Unit::Prefix::Mega, Unit::Name::Herz);
|
||||
case Bandwidth:
|
||||
return Unit(Unit::Prefix::Kilo, Unit::Name::Herz);
|
||||
case SpreadFactor:
|
||||
case CodingRate: // no break
|
||||
case SyncWord: // no break
|
||||
case PreambleLength: // no break
|
||||
return Unit(Unit::Name::None);
|
||||
case DataRate:
|
||||
return Unit(Unit::Prefix::Kilo, Unit::Name::BitsPerSecond);
|
||||
case FrequencyDeviation:
|
||||
return Unit(Unit::Prefix::Kilo, Unit::Name::Herz);
|
||||
case NarrowGrid:
|
||||
return Unit(Unit::Name::None);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TT_LOG_W(TAG, "Tried to get unit for unsupported parameter \"%s\"", toString(parameter));
|
||||
return Unit(Unit::Name::None);
|
||||
}
|
||||
|
||||
void Sx1262::registerDio1Isr() {
|
||||
gpio_hal_context_t gpiohal;
|
||||
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
|
||||
|
||||
gpio_config_t conf = {
|
||||
.pin_bit_mask = (1ULL<<configuration.irqPin),
|
||||
.mode = (gpio_mode_t)GPIO_MODE_INPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_ENABLE,
|
||||
.intr_type = (gpio_int_type_t)gpiohal.dev->pin[configuration.irqPin].int_type,
|
||||
};
|
||||
gpio_config(&conf);
|
||||
|
||||
// We cannot use the RadioLib API to register this action,
|
||||
// as it does not have the capability to pass an instance pointer via context.
|
||||
// A trampoline has been tried, but is not linkable to be in IRAM_ATTR (dangerous relocation).
|
||||
gpio_install_isr_service((int)ESP_INTR_FLAG_IRAM);
|
||||
gpio_set_intr_type(configuration.irqPin, GPIO_INTR_POSEDGE);
|
||||
gpio_isr_handler_add(configuration.irqPin, dio1handler, this);
|
||||
}
|
||||
|
||||
void Sx1262::unregisterDio1Isr() {
|
||||
gpio_isr_handler_remove(configuration.irqPin);
|
||||
gpio_wakeup_disable(configuration.irqPin);
|
||||
gpio_set_intr_type(configuration.irqPin, GPIO_INTR_DISABLE);
|
||||
}
|
||||
|
||||
void IRAM_ATTR Sx1262::dio1Event() {
|
||||
static const auto DRAM_ATTR bit = SX1262_DIO1_EVENT_BIT;
|
||||
events.set(bit);
|
||||
}
|
||||
|
||||
void Sx1262::txQueuedSignal() {
|
||||
events.set(SX1262_QUEUED_TX_BIT);
|
||||
}
|
||||
|
||||
void Sx1262::interruptSignal() {
|
||||
events.set(SX1262_INTERRUPT_BIT);
|
||||
}
|
||||
|
||||
int Sx1262::doBegin(const Modulation modulation) {
|
||||
uint16_t rc = RADIOLIB_ERR_NONE;
|
||||
|
||||
if (modulation == Modulation::LoRa) {
|
||||
rc = radio.begin(
|
||||
frequency,
|
||||
bandwidth,
|
||||
spreadFactor,
|
||||
codingRate,
|
||||
syncWord,
|
||||
power,
|
||||
preambleLength,
|
||||
configuration.tcxoVoltage,
|
||||
configuration.useRegulatorLdo
|
||||
);
|
||||
} else if (modulation == Modulation::Fsk) {
|
||||
rc = radio.beginFSK(
|
||||
frequency,
|
||||
bitRate,
|
||||
frequencyDeviation,
|
||||
bandwidth,
|
||||
power,
|
||||
preambleLength,
|
||||
configuration.tcxoVoltage,
|
||||
configuration.useRegulatorLdo
|
||||
);
|
||||
} else if (modulation == Modulation::LrFhss) {
|
||||
rc = radio.beginLRFHSS(
|
||||
bandwidth,
|
||||
codingRate,
|
||||
narrowGrid,
|
||||
configuration.tcxoVoltage,
|
||||
configuration.useRegulatorLdo
|
||||
);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "SX1262 not capable of modulation \"%s\"", toString(modulation));
|
||||
setState(State::Error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc != RADIOLIB_ERR_NONE) {
|
||||
TT_LOG_E(TAG, "Radiolib initialization failed with code %hi", rc);
|
||||
setState(State::Error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
registerDio1Isr();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sx1262::doEnd() {
|
||||
unregisterDio1Isr();
|
||||
}
|
||||
|
||||
void Sx1262::doTransmit() {
|
||||
currentTx = popNextQueuedTx();
|
||||
uint16_t rc = RADIOLIB_ERR_NONE;
|
||||
rc = radio.standby();
|
||||
if (rc != RADIOLIB_ERR_NONE) {
|
||||
TT_LOG_W(TAG, "RadioLib returned %hi on standby", rc);
|
||||
}
|
||||
|
||||
if (getModulation() == Modulation::Fsk) {
|
||||
rc = radio.startTransmit(currentTx.packet.data.data(), currentTx.packet.data.size(),
|
||||
currentTx.packet.address);
|
||||
} else {
|
||||
rc = radio.startTransmit(currentTx.packet.data.data(), currentTx.packet.data.size());
|
||||
}
|
||||
|
||||
if (rc == RADIOLIB_ERR_NONE) {
|
||||
currentTx.callback(currentTx.id, TransmissionState::PendingTransmit);
|
||||
|
||||
auto txEventFlags = events.wait(SX1262_INTERRUPT_BIT | SX1262_DIO1_EVENT_BIT, tt::EventFlag::WaitAny,
|
||||
pdMS_TO_TICKS(SX1262_TX_TIMEOUT_MILLIS));
|
||||
|
||||
// Thread might've been interrupted in the meanwhile
|
||||
if (isThreadInterrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the DIO1 bit is unset, this means the wait timed out
|
||||
if (txEventFlags & SX1262_DIO1_EVENT_BIT) {
|
||||
currentTx.callback(currentTx.id, TransmissionState::Transmitted);
|
||||
} else {
|
||||
currentTx.callback(currentTx.id, TransmissionState::Timeout);
|
||||
}
|
||||
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Error transmitting id=%d, rc=%hi", currentTx.id, rc);
|
||||
currentTx.callback(currentTx.id, TransmissionState::Error);
|
||||
}
|
||||
}
|
||||
|
||||
void Sx1262::doListen() {
|
||||
if (getModulation() != Modulation::LrFhss) {
|
||||
radio.startReceive();
|
||||
events.wait(SX1262_INTERRUPT_BIT | SX1262_DIO1_EVENT_BIT | SX1262_QUEUED_TX_BIT);
|
||||
} else {
|
||||
// LR-FHSS modem only supports TX
|
||||
events.wait(SX1262_INTERRUPT_BIT | SX1262_QUEUED_TX_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void Sx1262::doReceive() {
|
||||
// LR-FHSS modem only supports TX
|
||||
if (getModulation() == Modulation::LrFhss) return;
|
||||
|
||||
uint16_t rxSize = radio.getPacketLength(true);
|
||||
std::vector<uint8_t> data(rxSize);
|
||||
uint16_t rc = radio.readData(data.data(), rxSize);
|
||||
if (rc != RADIOLIB_ERR_NONE) {
|
||||
TT_LOG_E(TAG, "Error receiving data, RadioLib returned %hi", rc);
|
||||
} else if(rxSize == 0) {
|
||||
// This can cause a flood of messages if there are ones emitted here,
|
||||
// as a warning here doesn't bring that much to the table it is skipped.
|
||||
// The body is kept empty intentionally.'
|
||||
} else {
|
||||
float rssi = radio.getRSSI();
|
||||
float snr = radio.getSNR();
|
||||
auto rxPacket = tt::hal::radio::RxPacket {
|
||||
.data = data,
|
||||
.rssi = rssi,
|
||||
.snr = snr
|
||||
};
|
||||
|
||||
publishRx(rxPacket);
|
||||
}
|
||||
|
||||
// A delay before a new command improves reliability
|
||||
vTaskDelay(pdMS_TO_TICKS(SX1262_COOLDOWN_MILLIS));
|
||||
}
|
||||
|
||||
108
Drivers/SX126x/Source/Sx1262.h
Normal file
@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
#include <Tactility/EventFlag.h>
|
||||
#include <Tactility/Lock.h>
|
||||
|
||||
#include <RadioLib.h>
|
||||
#include "RadiolibTactilityHal.h"
|
||||
#include "RadiolibThreadedDevice.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
class Sx1262 final : public RadiolibThreadedDevice {
|
||||
|
||||
public:
|
||||
struct Configuration {
|
||||
spi_host_device_t spiHostDevice;
|
||||
int spiFrequency;
|
||||
gpio_num_t csPin;
|
||||
gpio_num_t resetPin;
|
||||
gpio_num_t busyPin;
|
||||
gpio_num_t irqPin;
|
||||
float tcxoVoltage;
|
||||
bool useRegulatorLdo;
|
||||
};
|
||||
|
||||
private:
|
||||
static constexpr auto SX1262_DEFAULT_NAME = "SX1262";
|
||||
static constexpr auto SX1262_COOLDOWN_MILLIS = 100;
|
||||
static constexpr auto SX1262_TX_TIMEOUT_MILLIS = 2000;
|
||||
static constexpr auto SX1262_INTERRUPT_BIT = BIT0;
|
||||
static constexpr auto SX1262_DIO1_EVENT_BIT = BIT1;
|
||||
static constexpr auto SX1262_QUEUED_TX_BIT = BIT2;
|
||||
|
||||
std::string name;
|
||||
const Configuration configuration;
|
||||
std::shared_ptr<tt::Lock> lock;
|
||||
tt::EventFlag events;
|
||||
RadiolibTactilityHal hal;
|
||||
Module radioModule;
|
||||
SX1262 radio;
|
||||
TxItem currentTx;
|
||||
|
||||
// Shared parameters which have a common lowest value are set here
|
||||
int8_t power = -9.0;
|
||||
float frequency = 150;
|
||||
float bandwidth = 0.0;
|
||||
uint8_t spreadFactor = 0.0;
|
||||
uint8_t codingRate = 0;
|
||||
uint8_t syncWord = 0;
|
||||
uint16_t preambleLength = 0;
|
||||
float bitRate = 0.0;
|
||||
float frequencyDeviation = 0.0;
|
||||
bool narrowGrid = false;
|
||||
|
||||
void registerDio1Isr();
|
||||
void unregisterDio1Isr();
|
||||
|
||||
ParameterStatus setLoraParameter(const Parameter parameter, const float value);
|
||||
ParameterStatus setFskParameter(const Parameter parameter, const float value);
|
||||
ParameterStatus setLrFhssParameter(const Parameter parameter, const float value);
|
||||
ParameterStatus getLoraParameter(const Parameter parameter, float &value) const;
|
||||
ParameterStatus getFskParameter(const Parameter parameter, float &value) const;
|
||||
ParameterStatus getLrFhssParameter(const Parameter parameter, float &value) const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void txQueuedSignal() override;
|
||||
virtual void interruptSignal() override;
|
||||
|
||||
virtual int doBegin(const Modulation modulation) override;
|
||||
virtual void doEnd() override;
|
||||
virtual void doTransmit() override;
|
||||
virtual void doListen() override;
|
||||
virtual void doReceive() override;
|
||||
|
||||
public:
|
||||
|
||||
explicit Sx1262(const Configuration& configuration, const std::string& name = SX1262_DEFAULT_NAME)
|
||||
: RadiolibThreadedDevice(name, 4096)
|
||||
, name(name)
|
||||
, configuration(configuration)
|
||||
, hal(configuration.spiHostDevice, configuration.spiFrequency, configuration.csPin)
|
||||
, radioModule(&hal, configuration.csPin, configuration.irqPin, configuration.resetPin, configuration.busyPin)
|
||||
, radio(&radioModule)
|
||||
{}
|
||||
|
||||
~Sx1262() override = default;
|
||||
|
||||
std::string getName() const override { return name; }
|
||||
std::string getDescription() const override { return "Semtech SX1262 LoRa, FSK and LR-FHSS capable radio"; }
|
||||
|
||||
ParameterStatus setParameter(const Parameter parameter, const float value) override;
|
||||
ParameterStatus getParameter(const Parameter parameter, float &value) const override;
|
||||
tt::hal::radio::Unit getParameterUnit(const Parameter parameter) const override;
|
||||
|
||||
bool canTransmit(const Modulation modulation) override {
|
||||
return (modulation == Modulation::Fsk) ||
|
||||
(modulation == Modulation::LoRa) ||
|
||||
(modulation == Modulation::LrFhss);
|
||||
}
|
||||
|
||||
bool canReceive(const Modulation modulation) override {
|
||||
return (modulation == Modulation::Fsk) || (modulation == Modulation::LoRa);
|
||||
}
|
||||
|
||||
void dio1Event();
|
||||
};
|
||||
@ -1,204 +0,0 @@
|
||||
#include "Calculator.h"
|
||||
#include "Stack.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctype.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
constexpr const char* TAG = "Calculator";
|
||||
|
||||
static int precedence(char op) {
|
||||
if (op == '+' || op == '-') return 1;
|
||||
if (op == '*' || op == '/') return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Calculator::button_event_cb(lv_event_t* e) {
|
||||
Calculator* self = static_cast<Calculator*>(lv_event_get_user_data(e));
|
||||
lv_obj_t* buttonmatrix = lv_event_get_current_target_obj(e);
|
||||
lv_event_code_t event_code = lv_event_get_code(e);
|
||||
uint32_t button_id = lv_buttonmatrix_get_selected_button(buttonmatrix);
|
||||
const char* button_text = lv_buttonmatrix_get_button_text(buttonmatrix, button_id);
|
||||
if (event_code == LV_EVENT_VALUE_CHANGED) {
|
||||
self->handleInput(button_text);
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::handleInput(const char* txt) {
|
||||
if (strcmp(txt, "C") == 0) {
|
||||
resetCalculator();
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(txt, "=") == 0) {
|
||||
evaluateExpression();
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(formulaBuffer) + strlen(txt) < sizeof(formulaBuffer) - 1) {
|
||||
if (newInput) {
|
||||
memset(formulaBuffer, 0, sizeof(formulaBuffer));
|
||||
newInput = false;
|
||||
}
|
||||
strcat(formulaBuffer, txt);
|
||||
lv_label_set_text(displayLabel, formulaBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
Dequeue<Str> Calculator::infixToRPN(const Str& infix) {
|
||||
Stack<char> opStack;
|
||||
Dequeue<Str> output;
|
||||
Str token;
|
||||
size_t i = 0;
|
||||
|
||||
while (i < infix.length()) {
|
||||
char ch = infix[i];
|
||||
|
||||
if (isdigit(ch)) {
|
||||
token.clear();
|
||||
while (i < infix.length() && (isdigit(infix[i]) || infix[i] == '.')) { token.append(infix[i++]); }
|
||||
output.pushBack(token);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '(') { opStack.push(ch); } else if (ch == ')') {
|
||||
while (!opStack.empty() && opStack.top() != '(') {
|
||||
output.pushBack(Str(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.pop();
|
||||
} else if (strchr("+-*/", ch)) {
|
||||
while (!opStack.empty() && precedence(opStack.top()) >= precedence(ch)) {
|
||||
output.pushBack(Str(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.push(ch);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
while (!opStack.empty()) {
|
||||
output.pushBack(Str(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double Calculator::evaluateRPN(Dequeue<Str> rpnQueue) {
|
||||
Stack<double> values;
|
||||
|
||||
while (!rpnQueue.empty()) {
|
||||
Str token = rpnQueue.front();
|
||||
rpnQueue.popFront();
|
||||
|
||||
if (isdigit(token[0])) {
|
||||
double d;
|
||||
sscanf(token.c_str(), "%lf", &d);
|
||||
values.push(d);
|
||||
} else if (strchr("+-*/", token[0])) {
|
||||
if (values.size() < 2) return 0;
|
||||
|
||||
double b = values.top();
|
||||
values.pop();
|
||||
double a = values.top();
|
||||
values.pop();
|
||||
|
||||
if (token[0] == '+') values.push(a + b);
|
||||
else if (token[0] == '-') values.push(a - b);
|
||||
else if (token[0] == '*') values.push(a * b);
|
||||
else if (token[0] == '/' && b != 0) values.push(a / b);
|
||||
}
|
||||
}
|
||||
|
||||
return values.empty() ? 0 : values.top();
|
||||
}
|
||||
void Calculator::evaluateExpression() {
|
||||
double result = computeFormula();
|
||||
|
||||
size_t formulaLen = strlen(formulaBuffer);
|
||||
size_t maxAvailable = sizeof(formulaBuffer) - formulaLen - 1;
|
||||
|
||||
if (maxAvailable > 10) {
|
||||
char resultBuffer[32];
|
||||
snprintf(resultBuffer, sizeof(resultBuffer), " = %.8g", result);
|
||||
strncat(formulaBuffer, resultBuffer, maxAvailable);
|
||||
} else { snprintf(formulaBuffer, sizeof(formulaBuffer), "%.8g", result); }
|
||||
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_label_set_text(resultLabel, formulaBuffer);
|
||||
newInput = true;
|
||||
}
|
||||
|
||||
double Calculator::computeFormula() {
|
||||
return evaluateRPN(infixToRPN(Str(formulaBuffer)));
|
||||
}
|
||||
|
||||
void Calculator::resetCalculator() {
|
||||
memset(formulaBuffer, 0, sizeof(formulaBuffer));
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_label_set_text(resultLabel, "");
|
||||
newInput = true;
|
||||
}
|
||||
|
||||
void Calculator::onShow(AppHandle appHandle, lv_obj_t* parent) {
|
||||
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
||||
|
||||
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(wrapper, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||
lv_obj_set_height(wrapper, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_grow(wrapper, 0);
|
||||
lv_obj_set_style_pad_top(wrapper, 4, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_bottom(wrapper, 4, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(wrapper, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_right(wrapper, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_column(wrapper, 40, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(wrapper, 0, 0);
|
||||
lv_obj_remove_flag(wrapper, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
displayLabel = lv_label_create(wrapper);
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_obj_set_width(displayLabel, LV_SIZE_CONTENT);
|
||||
lv_obj_set_align(displayLabel, LV_ALIGN_LEFT_MID);
|
||||
|
||||
resultLabel = lv_label_create(wrapper);
|
||||
lv_label_set_text(resultLabel, "");
|
||||
lv_obj_set_width(resultLabel, LV_SIZE_CONTENT);
|
||||
lv_obj_set_align(resultLabel, LV_ALIGN_RIGHT_MID);
|
||||
|
||||
static const char* btn_map[] = {
|
||||
"(", ")", "C", "/", "\n",
|
||||
"7", "8", "9", "*", "\n",
|
||||
"4", "5", "6", "-", "\n",
|
||||
"1", "2", "3", "+", "\n",
|
||||
"0", "=", "", "", ""
|
||||
};
|
||||
|
||||
lv_obj_t* buttonmatrix = lv_buttonmatrix_create(parent);
|
||||
lv_buttonmatrix_set_map(buttonmatrix, btn_map);
|
||||
|
||||
lv_obj_set_style_pad_all(buttonmatrix, 5, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_row(buttonmatrix, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_column(buttonmatrix, 5, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(buttonmatrix, 2, LV_PART_MAIN);
|
||||
lv_obj_set_style_bg_color(buttonmatrix, lv_palette_main(LV_PALETTE_BLUE), LV_PART_ITEMS);
|
||||
|
||||
if (lv_display_get_horizontal_resolution(nullptr) <= 240 || lv_display_get_vertical_resolution(nullptr) <= 240) {
|
||||
//small screens
|
||||
lv_obj_set_size(buttonmatrix, lv_pct(100), lv_pct(60));
|
||||
} else {
|
||||
//large screens
|
||||
lv_obj_set_size(buttonmatrix, lv_pct(100), lv_pct(80));
|
||||
}
|
||||
lv_obj_align(buttonmatrix, LV_ALIGN_BOTTOM_MID, 0, -5);
|
||||
|
||||
lv_obj_add_event_cb(buttonmatrix, button_event_cb, LV_EVENT_VALUE_CHANGED, this);
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_app.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include "Str.h"
|
||||
#include "Dequeue.h"
|
||||
|
||||
class Calculator {
|
||||
|
||||
lv_obj_t* displayLabel;
|
||||
lv_obj_t* resultLabel;
|
||||
char formulaBuffer[128] = {0}; // Stores the full input expression
|
||||
bool newInput = true;
|
||||
|
||||
static void button_event_cb(lv_event_t* e);
|
||||
void handleInput(const char* txt);
|
||||
void evaluateExpression();
|
||||
double computeFormula();
|
||||
static Dequeue<Str> infixToRPN(const Str& infix);
|
||||
static double evaluateRPN(Dequeue<Str> rpnQueue);
|
||||
void resetCalculator();
|
||||
|
||||
public:
|
||||
|
||||
void onShow(AppHandle context, lv_obj_t* parent);
|
||||
};
|
||||
@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dequeue.h"
|
||||
|
||||
template <typename DataType>
|
||||
class Stack {
|
||||
|
||||
Dequeue<DataType> dequeue;
|
||||
|
||||
public:
|
||||
|
||||
void push(DataType data) { dequeue.pushFront(data); }
|
||||
|
||||
void pop() { dequeue.popFront(); }
|
||||
|
||||
DataType top() const { return dequeue.front(); }
|
||||
|
||||
bool empty() const { return dequeue.empty(); }
|
||||
|
||||
int size() const { return dequeue.size(); }
|
||||
};
|
||||
@ -1,13 +0,0 @@
|
||||
[manifest]
|
||||
version=0.1
|
||||
[target]
|
||||
sdk=0.6.0-SNAPSHOT1
|
||||
platforms=esp32,esp32s3
|
||||
[app]
|
||||
id=com.bytewelder.calculator
|
||||
version=0.1.0
|
||||
name=Calculator
|
||||
description=Math is cool
|
||||
[author]
|
||||
name=ByteWelder
|
||||
website=https://bytewelder.com
|
||||
2
ExternalApps/GraphicsDemo/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
build*/
|
||||
.tactility/
|
||||
@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
if (DEFINED ENV{TACTILITY_SDK_PATH})
|
||||
set(TACTILITY_SDK_PATH $ENV{TACTILITY_SDK_PATH})
|
||||
else()
|
||||
set(TACTILITY_SDK_PATH "../../release/TactilitySDK")
|
||||
message(WARNING "⚠️ TACTILITY_SDK_PATH environment variable is not set, defaulting to ${TACTILITY_SDK_PATH}")
|
||||
endif()
|
||||
|
||||
include("${TACTILITY_SDK_PATH}/TactilitySDK.cmake")
|
||||
set(EXTRA_COMPONENT_DIRS ${TACTILITY_SDK_PATH})
|
||||
|
||||
project(GraphicsDemo)
|
||||
tactility_project(GraphicsDemo)
|
||||
@ -1,7 +0,0 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Include"
|
||||
REQUIRES TactilitySDK
|
||||
)
|
||||
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "drivers/DisplayDriver.h"
|
||||
#include "drivers/TouchDriver.h"
|
||||
|
||||
void runApplication(DisplayDriver* display, TouchDriver* touch);
|
||||
@ -1,125 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <esp_log.h>
|
||||
#include "drivers/Colors.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <tt_hal_display.h>
|
||||
|
||||
class PixelBuffer {
|
||||
uint16_t pixelWidth;
|
||||
uint16_t pixelHeight;
|
||||
ColorFormat colorFormat;
|
||||
uint8_t* data;
|
||||
|
||||
public:
|
||||
|
||||
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) :
|
||||
pixelWidth(pixelWidth),
|
||||
pixelHeight(pixelHeight),
|
||||
colorFormat(colorFormat)
|
||||
{
|
||||
data = static_cast<uint8_t*>(malloc(pixelWidth * pixelHeight * getPixelSize()));
|
||||
assert(data != nullptr);
|
||||
}
|
||||
|
||||
~PixelBuffer() {
|
||||
free(data);
|
||||
}
|
||||
|
||||
uint16_t getPixelWidth() const {
|
||||
return pixelWidth;
|
||||
}
|
||||
|
||||
uint16_t getPixelHeight() const {
|
||||
return pixelHeight;
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
return colorFormat;
|
||||
}
|
||||
|
||||
void* getData() const {
|
||||
return data;
|
||||
}
|
||||
|
||||
uint32_t getDataSize() const {
|
||||
return pixelWidth * pixelHeight * getPixelSize();
|
||||
}
|
||||
|
||||
void* getDataAtRow(uint16_t row) const {
|
||||
auto address = reinterpret_cast<uint32_t>(data) + (row * getRowDataSize());
|
||||
return reinterpret_cast<void*>(address);
|
||||
}
|
||||
|
||||
uint16_t getRowDataSize() const {
|
||||
return pixelWidth * getPixelSize();
|
||||
}
|
||||
|
||||
uint8_t getPixelSize() const {
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
return 1;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
case COLOR_FORMAT_BGR565_SWAPPED:
|
||||
case COLOR_FORMAT_RGB565:
|
||||
case COLOR_FORMAT_RGB565_SWAPPED:
|
||||
return 2;
|
||||
case COLOR_FORMAT_RGB888:
|
||||
return 3;
|
||||
default:
|
||||
// TODO: Crash with error
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* getPixelAddress(uint16_t x, uint16_t y) const {
|
||||
uint32_t offset = ((y * getPixelWidth()) + x) * getPixelSize();
|
||||
uint32_t address = reinterpret_cast<uint32_t>(data) + offset;
|
||||
return reinterpret_cast<uint8_t*>(address);
|
||||
}
|
||||
|
||||
void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const {
|
||||
auto address = getPixelAddress(x, y);
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
*address = *(address + 1);
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565: {
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
*address = *(address + 1);
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB888: {
|
||||
uint8_t pixel[3] = { r, g, b };
|
||||
memcpy(address, pixel, 3);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// NO-OP
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void clear(int value = 0) const {
|
||||
memset(data, value, getDataSize());
|
||||
}
|
||||
};
|
||||
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class Colors {
|
||||
|
||||
public:
|
||||
|
||||
static void rgb888ToRgb565(uint8_t red, uint8_t green, uint8_t blue, uint16_t* rgb565) {
|
||||
uint16_t _rgb565 = (red >> 3);
|
||||
_rgb565 = (_rgb565 << 6) | (green >> 2);
|
||||
_rgb565 = (_rgb565 << 5) | (blue >> 3);
|
||||
*rgb565 = _rgb565;
|
||||
}
|
||||
|
||||
static void rgb888ToBgr565(uint8_t red, uint8_t green, uint8_t blue, uint16_t* bgr565) {
|
||||
uint16_t _bgr565 = (blue >> 3);
|
||||
_bgr565 = (_bgr565 << 6) | (green >> 2);
|
||||
_bgr565 = (_bgr565 << 5) | (red >> 3);
|
||||
*bgr565 = _bgr565;
|
||||
}
|
||||
|
||||
static void rgb565ToRgb888(uint16_t rgb565, uint32_t* rgb888) {
|
||||
uint32_t _rgb565 = rgb565;
|
||||
uint8_t b = (_rgb565 >> 8) & 0xF8;
|
||||
uint8_t g = (_rgb565 >> 3) & 0xFC;
|
||||
uint8_t r = (_rgb565 << 3) & 0xF8;
|
||||
|
||||
uint8_t* r8p = reinterpret_cast<uint8_t*>(rgb888);
|
||||
uint8_t* g8p = r8p + 1;
|
||||
uint8_t* b8p = r8p + 2;
|
||||
|
||||
*r8p = r | ((r >> 3) & 0x7);
|
||||
*g8p = g | ((g >> 2) & 0x3);
|
||||
*b8p = b | ((b >> 3) & 0x7);
|
||||
}
|
||||
};
|
||||
@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_display.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_display_driver_*
|
||||
*/
|
||||
class DisplayDriver {
|
||||
|
||||
DisplayDriverHandle handle = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
explicit DisplayDriver(DeviceId id) {
|
||||
assert(tt_hal_display_driver_supported(id));
|
||||
handle = tt_hal_display_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
}
|
||||
|
||||
~DisplayDriver() {
|
||||
tt_hal_display_driver_free(handle);
|
||||
}
|
||||
|
||||
bool lock(TickType timeout = TT_MAX_TICKS) const {
|
||||
return tt_hal_display_driver_lock(handle, timeout);
|
||||
}
|
||||
|
||||
void unlock() const {
|
||||
tt_hal_display_driver_unlock(handle);
|
||||
}
|
||||
|
||||
uint16_t getWidth() const {
|
||||
return tt_hal_display_driver_get_pixel_width(handle);
|
||||
}
|
||||
|
||||
uint16_t getHeight() const {
|
||||
return tt_hal_display_driver_get_pixel_height(handle);
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
return tt_hal_display_driver_get_colorformat(handle);
|
||||
}
|
||||
|
||||
void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const {
|
||||
tt_hal_display_driver_draw_bitmap(handle, xStart, yStart, xEnd, yEnd, pixelData);
|
||||
}
|
||||
};
|
||||
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_touch.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_touch_driver_*
|
||||
*/
|
||||
class TouchDriver {
|
||||
|
||||
TouchDriverHandle handle = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
explicit TouchDriver(DeviceId id) {
|
||||
assert(tt_hal_touch_driver_supported(id));
|
||||
handle = tt_hal_touch_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
}
|
||||
|
||||
~TouchDriver() {
|
||||
tt_hal_touch_driver_free(handle);
|
||||
}
|
||||
|
||||
bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
|
||||
return tt_hal_touch_driver_get_touched_points(handle, x, y, strength, count, maxCount);
|
||||
}
|
||||
};
|
||||
@ -1,72 +0,0 @@
|
||||
#include "Application.h"
|
||||
#include "PixelBuffer.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include <tt_kernel.h>
|
||||
|
||||
constexpr auto TAG = "Application";
|
||||
|
||||
static bool isTouched(TouchDriver* touch) {
|
||||
uint16_t x, y, strength;
|
||||
uint8_t pointCount = 0;
|
||||
return touch->getTouchedPoints(&x, &y, &strength, &pointCount, 1);
|
||||
}
|
||||
|
||||
void createRgbRow(PixelBuffer& buffer) {
|
||||
uint8_t offset = buffer.getPixelWidth() / 3;
|
||||
for (int i = 0; i < buffer.getPixelWidth(); ++i) {
|
||||
if (i < offset) {
|
||||
buffer.setPixel(i, 0, 255, 0, 0);
|
||||
} else if (i < offset * 2) {
|
||||
buffer.setPixel(i, 0, 0, 255, 0);
|
||||
} else {
|
||||
buffer.setPixel(i, 0, 0, 0, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createRgbFadingRow(PixelBuffer& buffer) {
|
||||
uint8_t stroke = buffer.getPixelWidth() / 3;
|
||||
for (int i = 0; i < buffer.getPixelWidth(); ++i) {
|
||||
if (i < stroke) {
|
||||
auto color = i * 255 / stroke;
|
||||
buffer.setPixel(i, 0, color, 0, 0);
|
||||
} else if (i < stroke * 2) {
|
||||
auto color = (i - stroke) * 255 / stroke;
|
||||
buffer.setPixel(i, 0, 0, color, 0);
|
||||
} else {
|
||||
auto color = (i - (2*stroke)) * 255 / stroke;
|
||||
buffer.setPixel(i, 0, 0, 0, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void runApplication(DisplayDriver* display, TouchDriver* touch) {
|
||||
// Single row buffers
|
||||
PixelBuffer line_clear_buffer(display->getWidth(), 1, display->getColorFormat());
|
||||
line_clear_buffer.clear();
|
||||
PixelBuffer line_buffer(display->getWidth(), 1, display->getColorFormat());
|
||||
line_buffer.clear();
|
||||
|
||||
do {
|
||||
// Draw row by row
|
||||
// This is placed in a loop to test the SPI locking mechanismss
|
||||
for (int i = 0; i < display->getHeight(); i++) {
|
||||
|
||||
if (i == 0) {
|
||||
createRgbRow(line_buffer);
|
||||
} else if (i == display->getHeight() / 2) {
|
||||
createRgbFadingRow(line_buffer);
|
||||
}
|
||||
|
||||
display->lock();
|
||||
display->drawBitmap(0, i, display->getWidth(), i + 1, line_buffer.getData());
|
||||
display->unlock();
|
||||
}
|
||||
|
||||
// Give other tasks space to breathe
|
||||
// SPI displays would otherwise time out SPI SD card access
|
||||
tt_kernel_delay_ticks(1);
|
||||
} while (!isTouched(touch));
|
||||
}
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
#include "Application.h"
|
||||
#include "drivers/DisplayDriver.h"
|
||||
#include "drivers/TouchDriver.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <tt_app.h>
|
||||
#include <tt_app_alertdialog.h>
|
||||
#include <tt_lvgl.h>
|
||||
|
||||
constexpr auto TAG = "Main";
|
||||
|
||||
/** Find a DisplayDevice that supports the DisplayDriver interface */
|
||||
static bool findUsableDisplay(DeviceId& deviceId) {
|
||||
uint16_t display_count = 0;
|
||||
if (!tt_hal_device_find(DEVICE_TYPE_DISPLAY, &deviceId, &display_count, 1)) {
|
||||
ESP_LOGE(TAG, "No display device found");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tt_hal_display_driver_supported(deviceId)) {
|
||||
ESP_LOGE(TAG, "Display doesn't support driver mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Find a TouchDevice that supports the TouchDriver interface */
|
||||
static bool findUsableTouch(DeviceId& deviceId) {
|
||||
uint16_t touch_count = 0;
|
||||
if (!tt_hal_device_find(DEVICE_TYPE_TOUCH, &deviceId, &touch_count, 1)) {
|
||||
ESP_LOGE(TAG, "No touch device found");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tt_hal_touch_driver_supported(deviceId)) {
|
||||
ESP_LOGE(TAG, "Touch doesn't support driver mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void onCreate(AppHandle appHandle, void* data) {
|
||||
DeviceId display_id;
|
||||
if (!findUsableDisplay(display_id)) {
|
||||
tt_app_stop();
|
||||
tt_app_alertdialog_start("Error", "The display doesn't support the required features.", nullptr, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
DeviceId touch_id;
|
||||
if (!findUsableTouch(touch_id)) {
|
||||
tt_app_stop();
|
||||
tt_app_alertdialog_start("Error", "The touch driver doesn't support the required features.", nullptr, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop LVGL first (because it's currently using the drivers we want to use)
|
||||
tt_lvgl_stop();
|
||||
|
||||
ESP_LOGI(TAG, "Creating display driver");
|
||||
auto display = new DisplayDriver(display_id);
|
||||
|
||||
ESP_LOGI(TAG, "Creating touch driver");
|
||||
auto touch = new TouchDriver(touch_id);
|
||||
|
||||
// Run the main logic
|
||||
ESP_LOGI(TAG, "Running application");
|
||||
runApplication(display, touch);
|
||||
|
||||
ESP_LOGI(TAG, "Cleanup display driver");
|
||||
delete display;
|
||||
|
||||
ESP_LOGI(TAG, "Cleanup touch driver");
|
||||
delete touch;
|
||||
|
||||
ESP_LOGI(TAG, "Stopping application");
|
||||
tt_app_stop();
|
||||
}
|
||||
|
||||
static void onDestroy(AppHandle appHandle, void* data) {
|
||||
// Restart LVGL to resume rendering of regular apps
|
||||
if (!tt_lvgl_is_started()) {
|
||||
ESP_LOGI(TAG, "Restarting LVGL");
|
||||
tt_lvgl_start();
|
||||
}
|
||||
}
|
||||
|
||||
ExternalAppManifest manifest = {
|
||||
.onCreate = onCreate,
|
||||
.onDestroy = onDestroy
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
tt_app_register(&manifest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
[manifest]
|
||||
version=0.1
|
||||
[target]
|
||||
sdk=0.6.0-SNAPSHOT1
|
||||
platforms=esp32,esp32s3
|
||||
[app]
|
||||
id=com.bytewelder.graphicsdemo
|
||||
version=0.1.0
|
||||
name=Graphics Demo
|
||||
description=A graphics and touch driver demonstration
|
||||
[author]
|
||||
name=ByteWelder
|
||||
website=https://bytewelder.com
|
||||
@ -1,637 +0,0 @@
|
||||
import configparser
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import requests
|
||||
import tarfile
|
||||
import shutil
|
||||
import configparser
|
||||
|
||||
ttbuild_path = ".tactility"
|
||||
ttbuild_version = "2.1.1"
|
||||
ttbuild_cdn = "https://cdn.tactility.one"
|
||||
ttbuild_sdk_json_validity = 3600 # seconds
|
||||
ttport = 6666
|
||||
verbose = False
|
||||
use_local_sdk = False
|
||||
valid_platforms = ["esp32", "esp32s3"]
|
||||
|
||||
spinner_pattern = [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠹",
|
||||
"⠸",
|
||||
"⠼",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠧",
|
||||
"⠇",
|
||||
"⠏"
|
||||
]
|
||||
|
||||
if sys.platform == "win32":
|
||||
shell_color_red = ""
|
||||
shell_color_orange = ""
|
||||
shell_color_green = ""
|
||||
shell_color_purple = ""
|
||||
shell_color_cyan = ""
|
||||
shell_color_reset = ""
|
||||
else:
|
||||
shell_color_red = "\033[91m"
|
||||
shell_color_orange = "\033[93m"
|
||||
shell_color_green = "\033[32m"
|
||||
shell_color_purple = "\033[35m"
|
||||
shell_color_cyan = "\033[36m"
|
||||
shell_color_reset = "\033[m"
|
||||
|
||||
def print_help():
|
||||
print("Usage: python tactility.py [action] [options]")
|
||||
print("")
|
||||
print("Actions:")
|
||||
print(" build [esp32,esp32s3] Build the app. Optionally specify a platform.")
|
||||
print(" esp32: ESP32")
|
||||
print(" esp32s3: ESP32 S3")
|
||||
print(" clean Clean the build folders")
|
||||
print(" clearcache Clear the SDK cache")
|
||||
print(" updateself Update this tool")
|
||||
print(" run [ip] Run the application")
|
||||
print(" install [ip] Install the application")
|
||||
print(" uninstall [ip] Uninstall the application")
|
||||
print(" bir [ip] [esp32,esp32s3] Build, install then run. Optionally specify a platform.")
|
||||
print(" brrr [ip] [esp32,esp32s3] Functionally the same as \"bir\", but \"app goes brrr\" meme variant.")
|
||||
print("")
|
||||
print("Options:")
|
||||
print(" --help Show this commandline info")
|
||||
print(" --local-sdk Use SDK specified by environment variable TACTILITY_SDK_PATH")
|
||||
print(" --skip-build Run everything except the idf.py/CMake commands")
|
||||
print(" --verbose Show extra console output")
|
||||
|
||||
# region Core
|
||||
|
||||
def download_file(url, filepath):
|
||||
global verbose
|
||||
if verbose:
|
||||
print(f"Downloading from {url} to {filepath}")
|
||||
request = urllib.request.Request(
|
||||
url,
|
||||
data=None,
|
||||
headers={
|
||||
"User-Agent": f"Tactility Build Tool {ttbuild_version}"
|
||||
}
|
||||
)
|
||||
try:
|
||||
response = urllib.request.urlopen(request)
|
||||
file = open(filepath, mode="wb")
|
||||
file.write(response.read())
|
||||
file.close()
|
||||
return True
|
||||
except OSError as error:
|
||||
if verbose:
|
||||
print_error(f"Failed to fetch URL {url}\n{error}")
|
||||
return False
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{shell_color_orange}WARNING: {message}{shell_color_reset}")
|
||||
|
||||
def print_error(message):
|
||||
print(f"{shell_color_red}ERROR: {message}{shell_color_reset}")
|
||||
|
||||
def exit_with_error(message):
|
||||
print_error(message)
|
||||
sys.exit(1)
|
||||
|
||||
def get_url(ip, path):
|
||||
return f"http://{ip}:{ttport}{path}"
|
||||
|
||||
def read_properties_file(path):
|
||||
config = configparser.RawConfigParser()
|
||||
config.read(path)
|
||||
return config
|
||||
|
||||
#endregion Core
|
||||
|
||||
#region SDK helpers
|
||||
|
||||
def read_sdk_json():
|
||||
json_file_path = os.path.join(ttbuild_path, "sdk.json")
|
||||
json_file = open(json_file_path)
|
||||
return json.load(json_file)
|
||||
|
||||
def get_sdk_dir(version, platform):
|
||||
global use_local_sdk
|
||||
if use_local_sdk:
|
||||
return os.environ.get("TACTILITY_SDK_PATH")
|
||||
else:
|
||||
global ttbuild_cdn
|
||||
return os.path.join(ttbuild_path, f"{version}-{platform}", "TactilitySDK")
|
||||
|
||||
def get_sdk_root_dir(version, platform):
|
||||
global ttbuild_cdn
|
||||
return os.path.join(ttbuild_path, f"{version}-{platform}")
|
||||
|
||||
def get_sdk_url(version, platform):
|
||||
global ttbuild_cdn
|
||||
return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip"
|
||||
|
||||
def sdk_exists(version, platform):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
return os.path.isdir(sdk_dir)
|
||||
|
||||
def should_update_sdk_json():
|
||||
global ttbuild_cdn
|
||||
json_filepath = os.path.join(ttbuild_path, "sdk.json")
|
||||
if os.path.exists(json_filepath):
|
||||
json_modification_time = os.path.getmtime(json_filepath)
|
||||
now = time.time()
|
||||
global ttbuild_sdk_json_validity
|
||||
minimum_seconds_difference = ttbuild_sdk_json_validity
|
||||
return (now - json_modification_time) > minimum_seconds_difference
|
||||
else:
|
||||
return True
|
||||
|
||||
def update_sdk_json():
|
||||
global ttbuild_cdn, ttbuild_path
|
||||
json_url = f"{ttbuild_cdn}/sdk.json"
|
||||
json_filepath = os.path.join(ttbuild_path, "sdk.json")
|
||||
return download_file(json_url, json_filepath)
|
||||
|
||||
def should_fetch_sdkconfig_files(platform_targets):
|
||||
for platform in platform_targets:
|
||||
sdkconfig_filename = f"sdkconfig.app.{platform}"
|
||||
if not os.path.exists(os.path.join(ttbuild_path, sdkconfig_filename)):
|
||||
return True
|
||||
return False
|
||||
|
||||
def fetch_sdkconfig_files(platform_targets):
|
||||
for platform in platform_targets:
|
||||
sdkconfig_filename = f"sdkconfig.app.{platform}"
|
||||
target_path = os.path.join(ttbuild_path, sdkconfig_filename)
|
||||
if not download_file(f"{ttbuild_cdn}/{sdkconfig_filename}", target_path):
|
||||
exit_with_error(f"Failed to download sdkconfig file for {platform}")
|
||||
|
||||
#endregion SDK helpers
|
||||
|
||||
#region Validation
|
||||
|
||||
def validate_environment():
|
||||
if os.environ.get("IDF_PATH") is None:
|
||||
exit_with_error("Cannot find the Espressif IDF SDK. Ensure it is installed and that it is activated via $PATH_TO_IDF_SDK/export.sh")
|
||||
if not os.path.exists("manifest.properties"):
|
||||
exit_with_error("manifest.properties not found")
|
||||
if use_local_sdk == False and os.environ.get("TACTILITY_SDK_PATH") is not None:
|
||||
print_warning("TACTILITY_SDK_PATH is set, but will be ignored by this command.")
|
||||
print_warning("If you want to use it, use the 'build local' parameters.")
|
||||
elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None:
|
||||
exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.")
|
||||
|
||||
def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build):
|
||||
version_map = sdk_json["versions"]
|
||||
if not sdk_version in version_map:
|
||||
exit_with_error(f"Version not found: {sdk_version}")
|
||||
version_data = version_map[sdk_version]
|
||||
available_platforms = version_data["platforms"]
|
||||
for desired_platform in platforms_to_build:
|
||||
if not desired_platform in available_platforms:
|
||||
exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}")
|
||||
|
||||
def validate_self(sdk_json):
|
||||
if not "toolVersion" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolVersion not found)")
|
||||
if not "toolCompatibility" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolCompatibility not found)")
|
||||
if not "toolDownloadUrl" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolDownloadUrl not found)")
|
||||
tool_version = sdk_json["toolVersion"]
|
||||
tool_compatibility = sdk_json["toolCompatibility"]
|
||||
if tool_version != ttbuild_version:
|
||||
print_warning(f"New version available: {tool_version} (currently using {ttbuild_version})")
|
||||
print_warning(f"Run 'tactility.py updateself' to update.")
|
||||
if re.search(tool_compatibility, ttbuild_version) is None:
|
||||
print_error("The tool is not compatible anymore.")
|
||||
print_error("Run 'tactility.py updateself' to update.")
|
||||
sys.exit(1)
|
||||
|
||||
#endregion Validation
|
||||
|
||||
#region Manifest
|
||||
|
||||
def read_manifest():
|
||||
return read_properties_file("manifest.properties")
|
||||
|
||||
def validate_manifest(manifest):
|
||||
# [manifest]
|
||||
if not "manifest" in manifest:
|
||||
exit_with_error("Invalid manifest format: [manifest] not found")
|
||||
if not "version" in manifest["manifest"]:
|
||||
exit_with_error("Invalid manifest format: [manifest] version not found")
|
||||
# [target]
|
||||
if not "target" in manifest:
|
||||
exit_with_error("Invalid manifest format: [target] not found")
|
||||
if not "sdk" in manifest["target"]:
|
||||
exit_with_error("Invalid manifest format: [target] sdk not found")
|
||||
if not "platforms" in manifest["target"]:
|
||||
exit_with_error("Invalid manifest format: [target] platforms not found")
|
||||
# [app]
|
||||
if not "app" in manifest:
|
||||
exit_with_error("Invalid manifest format: [app] not found")
|
||||
if not "id" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] id not found")
|
||||
if not "version" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] version not found")
|
||||
if not "name" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] name not found")
|
||||
if not "description" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] description not found")
|
||||
# [author]
|
||||
if not "author" in manifest:
|
||||
exit_with_error("Invalid manifest format: [author] not found")
|
||||
if not "name" in manifest["author"]:
|
||||
exit_with_error("Invalid manifest format: [author] name not found")
|
||||
if not "website" in manifest["author"]:
|
||||
exit_with_error("Invalid manifest format: [author] website not found")
|
||||
|
||||
def is_valid_manifest_platform(manifest, platform):
|
||||
manifest_platforms = manifest["target"]["platforms"].split(",")
|
||||
return platform in manifest_platforms
|
||||
|
||||
def validate_manifest_platform(manifest, platform):
|
||||
if not is_valid_manifest_platform(manifest, platform):
|
||||
exit_with_error(f"Platform {platform} is not available in the manifest.")
|
||||
|
||||
def get_manifest_target_platforms(manifest, requested_platform):
|
||||
if requested_platform == "" or requested_platform is None:
|
||||
return manifest["target"]["platforms"].split(",")
|
||||
else:
|
||||
validate_manifest_platform(manifest, requested_platform)
|
||||
return [requested_platform]
|
||||
|
||||
#endregion Manifest
|
||||
|
||||
#region SDK download
|
||||
|
||||
def sdk_download(version, platform):
|
||||
sdk_root_dir = get_sdk_root_dir(version, platform)
|
||||
os.makedirs(sdk_root_dir, exist_ok=True)
|
||||
sdk_url = get_sdk_url(version, platform)
|
||||
filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip")
|
||||
print(f"Downloading SDK version {version} for {platform}")
|
||||
if download_file(sdk_url, filepath):
|
||||
with zipfile.ZipFile(filepath, "r") as zip_ref:
|
||||
zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK"))
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def sdk_download_all(version, platforms):
|
||||
for platform in platforms:
|
||||
if not sdk_exists(version, platform):
|
||||
if not sdk_download(version, platform):
|
||||
return False
|
||||
else:
|
||||
if verbose:
|
||||
print(f"Using cached download for SDK version {version} and platform {platform}")
|
||||
return True
|
||||
|
||||
#endregion SDK download
|
||||
|
||||
#region Building
|
||||
|
||||
def get_cmake_path(platform):
|
||||
return os.path.join("build", f"cmake-build-{platform}")
|
||||
|
||||
def find_elf_file(platform):
|
||||
cmake_dir = get_cmake_path(platform)
|
||||
if os.path.exists(cmake_dir):
|
||||
for file in os.listdir(cmake_dir):
|
||||
if file.endswith(".app.elf"):
|
||||
return os.path.join(cmake_dir, file)
|
||||
return None
|
||||
|
||||
def build_all(version, platforms, skip_build):
|
||||
for platform in platforms:
|
||||
# First build command must be "idf.py build", otherwise it fails to execute "idf.py elf"
|
||||
# We check if the ELF file exists and run the correct command
|
||||
# This can lead to code caching issues, so sometimes a clean build is required
|
||||
if find_elf_file(platform) is None:
|
||||
if not build_first(version, platform, skip_build):
|
||||
break
|
||||
else:
|
||||
if not build_consecutively(version, platform, skip_build):
|
||||
break
|
||||
|
||||
def wait_for_build(process, platform):
|
||||
buffer = []
|
||||
os.set_blocking(process.stdout.fileno(), False)
|
||||
while process.poll() is None:
|
||||
for i in spinner_pattern:
|
||||
time.sleep(0.1)
|
||||
progress_text = f"Building for {platform} {shell_color_cyan}" + str(i) + shell_color_reset
|
||||
sys.stdout.write(progress_text + "\r")
|
||||
while True:
|
||||
line = process.stdout.readline()
|
||||
decoded_line = line.decode("UTF-8")
|
||||
if decoded_line != "":
|
||||
buffer.append(decoded_line)
|
||||
else:
|
||||
break
|
||||
return buffer
|
||||
|
||||
# The first build must call "idf.py build" and consecutive builds must call "idf.py elf" as it finishes faster.
|
||||
# The problem is that the "idf.py build" always results in an error, even though the elf file is created.
|
||||
# The solution is to suppress the error if we find that the elf file was created.
|
||||
def build_first(version, platform, skip_build):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
if verbose:
|
||||
print(f"Using SDK at {sdk_dir}")
|
||||
os.environ["TACTILITY_SDK_PATH"] = sdk_dir
|
||||
sdkconfig_path = os.path.join(ttbuild_path, f"sdkconfig.app.{platform}")
|
||||
os.system(f"cp {sdkconfig_path} sdkconfig")
|
||||
elf_path = find_elf_file(platform)
|
||||
# Remove previous elf file: re-creation of the file is used to measure if the build succeeded,
|
||||
# as the actual build job will always fail due to technical issues with the elf cmake script
|
||||
if elf_path is not None:
|
||||
os.remove(elf_path)
|
||||
if skip_build:
|
||||
return True
|
||||
print("Building first build")
|
||||
cmake_path = get_cmake_path(platform)
|
||||
with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process:
|
||||
build_output = wait_for_build(process, platform)
|
||||
# The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case
|
||||
if process.returncode == 0:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
else:
|
||||
if find_elf_file(platform) is None:
|
||||
for line in build_output:
|
||||
print(line, end="")
|
||||
print(f"{shell_color_red}Building for {platform} failed ❌{shell_color_reset}")
|
||||
return False
|
||||
else:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
|
||||
def build_consecutively(version, platform, skip_build):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
if verbose:
|
||||
print(f"Using SDK at {sdk_dir}")
|
||||
os.environ["TACTILITY_SDK_PATH"] = sdk_dir
|
||||
sdkconfig_path = os.path.join(ttbuild_path, f"sdkconfig.app.{platform}")
|
||||
os.system(f"cp {sdkconfig_path} sdkconfig")
|
||||
if skip_build:
|
||||
return True
|
||||
cmake_path = get_cmake_path(platform)
|
||||
with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process:
|
||||
build_output = wait_for_build(process, platform)
|
||||
if process.returncode == 0:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
else:
|
||||
for line in build_output:
|
||||
print(line, end="")
|
||||
print(f"{shell_color_red}Building for {platform} failed ❌{shell_color_reset}")
|
||||
return False
|
||||
|
||||
#endregion Building
|
||||
|
||||
#region Packaging
|
||||
|
||||
def package_intermediate_manifest(target_path):
|
||||
if not os.path.isfile("manifest.properties"):
|
||||
print_error("manifest.properties not found")
|
||||
return
|
||||
shutil.copy("manifest.properties", os.path.join(target_path, "manifest.properties"))
|
||||
|
||||
def package_intermediate_binaries(target_path, platforms):
|
||||
elf_dir = os.path.join(target_path, "elf")
|
||||
os.makedirs(elf_dir, exist_ok=True)
|
||||
for platform in platforms:
|
||||
elf_path = find_elf_file(platform)
|
||||
if elf_path is None:
|
||||
print_error(f"ELF file not found at {elf_path}")
|
||||
return
|
||||
shutil.copy(elf_path, os.path.join(elf_dir, f"{platform}.elf"))
|
||||
|
||||
def package_intermediate_assets(target_path):
|
||||
if os.path.isdir("assets"):
|
||||
shutil.copytree("assets", os.path.join(target_path, "assets"), dirs_exist_ok=True)
|
||||
|
||||
def package_intermediate(platforms):
|
||||
target_path = os.path.join("build", "package-intermediate")
|
||||
if os.path.isdir(target_path):
|
||||
shutil.rmtree(target_path)
|
||||
os.makedirs(target_path, exist_ok=True)
|
||||
package_intermediate_manifest(target_path)
|
||||
package_intermediate_binaries(target_path, platforms)
|
||||
package_intermediate_assets(target_path)
|
||||
|
||||
def package_name(platforms):
|
||||
elf_path = find_elf_file(platforms[0])
|
||||
elf_base_name = os.path.basename(elf_path).removesuffix(".app.elf")
|
||||
return os.path.join("build", f"{elf_base_name}.app")
|
||||
|
||||
def package_all(platforms):
|
||||
print("Packaging app")
|
||||
package_intermediate(platforms)
|
||||
# Create build/something.app
|
||||
tar_path = package_name(platforms)
|
||||
tar = tarfile.open(tar_path, mode="w", format=tarfile.USTAR_FORMAT)
|
||||
tar.add(os.path.join("build", "package-intermediate"), arcname="")
|
||||
tar.close()
|
||||
|
||||
#endregion Packaging
|
||||
|
||||
def setup_environment():
|
||||
global ttbuild_path
|
||||
os.makedirs(ttbuild_path, exist_ok=True)
|
||||
|
||||
def build_action(manifest, platform_arg):
|
||||
# Environment validation
|
||||
validate_environment()
|
||||
platforms_to_build = get_manifest_target_platforms(manifest, platform_arg)
|
||||
if not use_local_sdk:
|
||||
if should_fetch_sdkconfig_files(platforms_to_build):
|
||||
fetch_sdkconfig_files(platforms_to_build)
|
||||
sdk_json = read_sdk_json()
|
||||
validate_self(sdk_json)
|
||||
if not "versions" in sdk_json:
|
||||
exit_with_error("Version data not found in sdk.json")
|
||||
# Build
|
||||
sdk_version = manifest["target"]["sdk"]
|
||||
if not use_local_sdk:
|
||||
validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build)
|
||||
if not sdk_download_all(sdk_version, platforms_to_build):
|
||||
exit_with_error("Failed to download one or more SDKs")
|
||||
build_all(sdk_version, platforms_to_build, skip_build) # Environment validation
|
||||
if not skip_build:
|
||||
package_all(platforms_to_build)
|
||||
|
||||
def clean_action():
|
||||
if os.path.exists("build"):
|
||||
print(f"Removing build/")
|
||||
shutil.rmtree("build")
|
||||
else:
|
||||
print("Nothing to clean")
|
||||
|
||||
def clear_cache_action():
|
||||
if os.path.exists(ttbuild_path):
|
||||
print(f"Removing {ttbuild_path}/")
|
||||
shutil.rmtree(ttbuild_path)
|
||||
else:
|
||||
print("Nothing to clear")
|
||||
|
||||
def update_self_action():
|
||||
sdk_json = read_sdk_json()
|
||||
tool_download_url = sdk_json["toolDownloadUrl"]
|
||||
if download_file(tool_download_url, "tactility.py"):
|
||||
print("Updated")
|
||||
else:
|
||||
exit_with_error("Update failed")
|
||||
|
||||
def get_device_info(ip):
|
||||
print(f"Getting device info from {ip}")
|
||||
url = get_url(ip, "/info")
|
||||
try:
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
print_error("Run failed")
|
||||
else:
|
||||
print(response.json())
|
||||
print(f"{shell_color_green}Run successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
|
||||
def run_action(manifest, ip):
|
||||
app_id = manifest["app"]["id"]
|
||||
print(f"Running {app_id} on {ip}")
|
||||
url = get_url(ip, "/app/run")
|
||||
params = {'id': app_id}
|
||||
try:
|
||||
response = requests.post(url, params=params)
|
||||
if response.status_code != 200:
|
||||
print_error("Run failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Run successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
|
||||
def install_action(ip, platforms):
|
||||
for platform in platforms:
|
||||
elf_path = find_elf_file(platform)
|
||||
if elf_path is None:
|
||||
exit_with_error(f"ELF file not built for {platform}")
|
||||
package_path = package_name(platforms)
|
||||
print(f"Installing {package_path} to {ip}")
|
||||
url = get_url(ip, "/app/install")
|
||||
try:
|
||||
# Prepare multipart form data
|
||||
with open(package_path, 'rb') as file:
|
||||
files = {
|
||||
'elf': file
|
||||
}
|
||||
response = requests.put(url, files=files)
|
||||
if response.status_code != 200:
|
||||
print_error("Install failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Installation successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print_error(f"Installation failed: {e}")
|
||||
except IOError as e:
|
||||
print_error(f"File error: {e}")
|
||||
|
||||
def uninstall_action(manifest, ip):
|
||||
app_id = manifest["app"]["id"]
|
||||
print(f"Uninstalling {app_id} on {ip}")
|
||||
url = get_url(ip, "/app/uninstall")
|
||||
params = {'id': app_id}
|
||||
try:
|
||||
response = requests.put(url, params=params)
|
||||
if response.status_code != 200:
|
||||
print_error("Uninstall failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Uninstall successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
#region Main
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Tactility Build System v{ttbuild_version}")
|
||||
if "--help" in sys.argv:
|
||||
print_help()
|
||||
sys.exit()
|
||||
# Argument validation
|
||||
if len(sys.argv) == 1:
|
||||
print_help()
|
||||
sys.exit()
|
||||
action_arg = sys.argv[1]
|
||||
verbose = "--verbose" in sys.argv
|
||||
skip_build = "--skip-build" in sys.argv
|
||||
use_local_sdk = "--local-sdk" in sys.argv
|
||||
# Environment setup
|
||||
setup_environment()
|
||||
if not os.path.isfile("manifest.properties"):
|
||||
exit_with_error("manifest.properties not found")
|
||||
manifest = read_manifest()
|
||||
validate_manifest(manifest)
|
||||
all_platform_targets = manifest["target"]["platforms"].split(",")
|
||||
# Update SDK cache (sdk.json)
|
||||
if should_update_sdk_json() and not update_sdk_json():
|
||||
exit_with_error("Failed to retrieve SDK info")
|
||||
# Actions
|
||||
if action_arg == "build":
|
||||
if len(sys.argv) < 2:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
if len(sys.argv) > 2:
|
||||
platform = sys.argv[2]
|
||||
build_action(manifest, platform)
|
||||
elif action_arg == "clean":
|
||||
clean_action()
|
||||
elif action_arg == "clearcache":
|
||||
clear_cache_action()
|
||||
elif action_arg == "updateself":
|
||||
update_self_action()
|
||||
elif action_arg == "run":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
run_action(manifest, sys.argv[2])
|
||||
elif action_arg == "install":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
platforms_to_install = all_platform_targets
|
||||
if len(sys.argv) >= 4:
|
||||
platform = sys.argv[3]
|
||||
platforms_to_install = [platform]
|
||||
install_action(sys.argv[2], platforms_to_install)
|
||||
elif action_arg == "uninstall":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
uninstall_action(manifest, sys.argv[2])
|
||||
elif action_arg == "bir" or action_arg == "brrr":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
platforms_to_install = all_platform_targets
|
||||
if len(sys.argv) >= 4:
|
||||
platform = sys.argv[3]
|
||||
platforms_to_install = [platform]
|
||||
build_action(manifest, platform)
|
||||
install_action(sys.argv[2], platforms_to_install)
|
||||
run_action(manifest, sys.argv[2])
|
||||
else:
|
||||
print_help()
|
||||
exit_with_error("Unknown commandline parameter")
|
||||
|
||||
#endregion Main
|
||||
2
ExternalApps/HelloWorld/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
build/
|
||||
.tactility/
|
||||
@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
if (DEFINED ENV{TACTILITY_SDK_PATH})
|
||||
set(TACTILITY_SDK_PATH $ENV{TACTILITY_SDK_PATH})
|
||||
else()
|
||||
set(TACTILITY_SDK_PATH "../../release/TactilitySDK")
|
||||
message(WARNING "⚠️ TACTILITY_SDK_PATH environment variable is not set, defaulting to ${TACTILITY_SDK_PATH}")
|
||||
endif()
|
||||
|
||||
include("${TACTILITY_SDK_PATH}/TactilitySDK.cmake")
|
||||
set(EXTRA_COMPONENT_DIRS ${TACTILITY_SDK_PATH})
|
||||
|
||||
project(HelloWorld)
|
||||
tactility_project(HelloWorld)
|
||||
@ -1 +0,0 @@
|
||||
Hello, world!
|
||||
@ -1,6 +0,0 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
REQUIRES TactilitySDK
|
||||
)
|
||||
@ -1,24 +0,0 @@
|
||||
#include <tt_app_manifest.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
/**
|
||||
* Note: LVGL and Tactility methods need to be exposed manually from TactilityC/Source/tt_init.cpp
|
||||
* Only C is supported for now (C++ symbols fail to link)
|
||||
*/
|
||||
static void onShow(AppHandle app, void* data, lv_obj_t* parent) {
|
||||
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* label = lv_label_create(parent);
|
||||
lv_label_set_text(label, "Hello, world!");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
ExternalAppManifest manifest = {
|
||||
.onShow = onShow
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
tt_app_register(&manifest);
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
[manifest]
|
||||
version=0.1
|
||||
[target]
|
||||
sdk=0.6.0-SNAPSHOT1
|
||||
platforms=esp32,esp32s3
|
||||
[app]
|
||||
id=com.bytewelder.helloworld
|
||||
version=0.1.0
|
||||
name=Hello World
|
||||
description=A demonstration app that says hi
|
||||
[author]
|
||||
name=ByteWelder
|
||||
website=https://bytewelder.com
|
||||
@ -1,637 +0,0 @@
|
||||
import configparser
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import requests
|
||||
import tarfile
|
||||
import shutil
|
||||
import configparser
|
||||
|
||||
ttbuild_path = ".tactility"
|
||||
ttbuild_version = "2.1.1"
|
||||
ttbuild_cdn = "https://cdn.tactility.one"
|
||||
ttbuild_sdk_json_validity = 3600 # seconds
|
||||
ttport = 6666
|
||||
verbose = False
|
||||
use_local_sdk = False
|
||||
valid_platforms = ["esp32", "esp32s3"]
|
||||
|
||||
spinner_pattern = [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠹",
|
||||
"⠸",
|
||||
"⠼",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠧",
|
||||
"⠇",
|
||||
"⠏"
|
||||
]
|
||||
|
||||
if sys.platform == "win32":
|
||||
shell_color_red = ""
|
||||
shell_color_orange = ""
|
||||
shell_color_green = ""
|
||||
shell_color_purple = ""
|
||||
shell_color_cyan = ""
|
||||
shell_color_reset = ""
|
||||
else:
|
||||
shell_color_red = "\033[91m"
|
||||
shell_color_orange = "\033[93m"
|
||||
shell_color_green = "\033[32m"
|
||||
shell_color_purple = "\033[35m"
|
||||
shell_color_cyan = "\033[36m"
|
||||
shell_color_reset = "\033[m"
|
||||
|
||||
def print_help():
|
||||
print("Usage: python tactility.py [action] [options]")
|
||||
print("")
|
||||
print("Actions:")
|
||||
print(" build [esp32,esp32s3] Build the app. Optionally specify a platform.")
|
||||
print(" esp32: ESP32")
|
||||
print(" esp32s3: ESP32 S3")
|
||||
print(" clean Clean the build folders")
|
||||
print(" clearcache Clear the SDK cache")
|
||||
print(" updateself Update this tool")
|
||||
print(" run [ip] Run the application")
|
||||
print(" install [ip] Install the application")
|
||||
print(" uninstall [ip] Uninstall the application")
|
||||
print(" bir [ip] [esp32,esp32s3] Build, install then run. Optionally specify a platform.")
|
||||
print(" brrr [ip] [esp32,esp32s3] Functionally the same as \"bir\", but \"app goes brrr\" meme variant.")
|
||||
print("")
|
||||
print("Options:")
|
||||
print(" --help Show this commandline info")
|
||||
print(" --local-sdk Use SDK specified by environment variable TACTILITY_SDK_PATH")
|
||||
print(" --skip-build Run everything except the idf.py/CMake commands")
|
||||
print(" --verbose Show extra console output")
|
||||
|
||||
# region Core
|
||||
|
||||
def download_file(url, filepath):
|
||||
global verbose
|
||||
if verbose:
|
||||
print(f"Downloading from {url} to {filepath}")
|
||||
request = urllib.request.Request(
|
||||
url,
|
||||
data=None,
|
||||
headers={
|
||||
"User-Agent": f"Tactility Build Tool {ttbuild_version}"
|
||||
}
|
||||
)
|
||||
try:
|
||||
response = urllib.request.urlopen(request)
|
||||
file = open(filepath, mode="wb")
|
||||
file.write(response.read())
|
||||
file.close()
|
||||
return True
|
||||
except OSError as error:
|
||||
if verbose:
|
||||
print_error(f"Failed to fetch URL {url}\n{error}")
|
||||
return False
|
||||
|
||||
def print_warning(message):
|
||||
print(f"{shell_color_orange}WARNING: {message}{shell_color_reset}")
|
||||
|
||||
def print_error(message):
|
||||
print(f"{shell_color_red}ERROR: {message}{shell_color_reset}")
|
||||
|
||||
def exit_with_error(message):
|
||||
print_error(message)
|
||||
sys.exit(1)
|
||||
|
||||
def get_url(ip, path):
|
||||
return f"http://{ip}:{ttport}{path}"
|
||||
|
||||
def read_properties_file(path):
|
||||
config = configparser.RawConfigParser()
|
||||
config.read(path)
|
||||
return config
|
||||
|
||||
#endregion Core
|
||||
|
||||
#region SDK helpers
|
||||
|
||||
def read_sdk_json():
|
||||
json_file_path = os.path.join(ttbuild_path, "sdk.json")
|
||||
json_file = open(json_file_path)
|
||||
return json.load(json_file)
|
||||
|
||||
def get_sdk_dir(version, platform):
|
||||
global use_local_sdk
|
||||
if use_local_sdk:
|
||||
return os.environ.get("TACTILITY_SDK_PATH")
|
||||
else:
|
||||
global ttbuild_cdn
|
||||
return os.path.join(ttbuild_path, f"{version}-{platform}", "TactilitySDK")
|
||||
|
||||
def get_sdk_root_dir(version, platform):
|
||||
global ttbuild_cdn
|
||||
return os.path.join(ttbuild_path, f"{version}-{platform}")
|
||||
|
||||
def get_sdk_url(version, platform):
|
||||
global ttbuild_cdn
|
||||
return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip"
|
||||
|
||||
def sdk_exists(version, platform):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
return os.path.isdir(sdk_dir)
|
||||
|
||||
def should_update_sdk_json():
|
||||
global ttbuild_cdn
|
||||
json_filepath = os.path.join(ttbuild_path, "sdk.json")
|
||||
if os.path.exists(json_filepath):
|
||||
json_modification_time = os.path.getmtime(json_filepath)
|
||||
now = time.time()
|
||||
global ttbuild_sdk_json_validity
|
||||
minimum_seconds_difference = ttbuild_sdk_json_validity
|
||||
return (now - json_modification_time) > minimum_seconds_difference
|
||||
else:
|
||||
return True
|
||||
|
||||
def update_sdk_json():
|
||||
global ttbuild_cdn, ttbuild_path
|
||||
json_url = f"{ttbuild_cdn}/sdk.json"
|
||||
json_filepath = os.path.join(ttbuild_path, "sdk.json")
|
||||
return download_file(json_url, json_filepath)
|
||||
|
||||
def should_fetch_sdkconfig_files(platform_targets):
|
||||
for platform in platform_targets:
|
||||
sdkconfig_filename = f"sdkconfig.app.{platform}"
|
||||
if not os.path.exists(os.path.join(ttbuild_path, sdkconfig_filename)):
|
||||
return True
|
||||
return False
|
||||
|
||||
def fetch_sdkconfig_files(platform_targets):
|
||||
for platform in platform_targets:
|
||||
sdkconfig_filename = f"sdkconfig.app.{platform}"
|
||||
target_path = os.path.join(ttbuild_path, sdkconfig_filename)
|
||||
if not download_file(f"{ttbuild_cdn}/{sdkconfig_filename}", target_path):
|
||||
exit_with_error(f"Failed to download sdkconfig file for {platform}")
|
||||
|
||||
#endregion SDK helpers
|
||||
|
||||
#region Validation
|
||||
|
||||
def validate_environment():
|
||||
if os.environ.get("IDF_PATH") is None:
|
||||
exit_with_error("Cannot find the Espressif IDF SDK. Ensure it is installed and that it is activated via $PATH_TO_IDF_SDK/export.sh")
|
||||
if not os.path.exists("manifest.properties"):
|
||||
exit_with_error("manifest.properties not found")
|
||||
if use_local_sdk == False and os.environ.get("TACTILITY_SDK_PATH") is not None:
|
||||
print_warning("TACTILITY_SDK_PATH is set, but will be ignored by this command.")
|
||||
print_warning("If you want to use it, use the 'build local' parameters.")
|
||||
elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None:
|
||||
exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.")
|
||||
|
||||
def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build):
|
||||
version_map = sdk_json["versions"]
|
||||
if not sdk_version in version_map:
|
||||
exit_with_error(f"Version not found: {sdk_version}")
|
||||
version_data = version_map[sdk_version]
|
||||
available_platforms = version_data["platforms"]
|
||||
for desired_platform in platforms_to_build:
|
||||
if not desired_platform in available_platforms:
|
||||
exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}")
|
||||
|
||||
def validate_self(sdk_json):
|
||||
if not "toolVersion" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolVersion not found)")
|
||||
if not "toolCompatibility" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolCompatibility not found)")
|
||||
if not "toolDownloadUrl" in sdk_json:
|
||||
exit_with_error("Server returned invalid SDK data format (toolDownloadUrl not found)")
|
||||
tool_version = sdk_json["toolVersion"]
|
||||
tool_compatibility = sdk_json["toolCompatibility"]
|
||||
if tool_version != ttbuild_version:
|
||||
print_warning(f"New version available: {tool_version} (currently using {ttbuild_version})")
|
||||
print_warning(f"Run 'tactility.py updateself' to update.")
|
||||
if re.search(tool_compatibility, ttbuild_version) is None:
|
||||
print_error("The tool is not compatible anymore.")
|
||||
print_error("Run 'tactility.py updateself' to update.")
|
||||
sys.exit(1)
|
||||
|
||||
#endregion Validation
|
||||
|
||||
#region Manifest
|
||||
|
||||
def read_manifest():
|
||||
return read_properties_file("manifest.properties")
|
||||
|
||||
def validate_manifest(manifest):
|
||||
# [manifest]
|
||||
if not "manifest" in manifest:
|
||||
exit_with_error("Invalid manifest format: [manifest] not found")
|
||||
if not "version" in manifest["manifest"]:
|
||||
exit_with_error("Invalid manifest format: [manifest] version not found")
|
||||
# [target]
|
||||
if not "target" in manifest:
|
||||
exit_with_error("Invalid manifest format: [target] not found")
|
||||
if not "sdk" in manifest["target"]:
|
||||
exit_with_error("Invalid manifest format: [target] sdk not found")
|
||||
if not "platforms" in manifest["target"]:
|
||||
exit_with_error("Invalid manifest format: [target] platforms not found")
|
||||
# [app]
|
||||
if not "app" in manifest:
|
||||
exit_with_error("Invalid manifest format: [app] not found")
|
||||
if not "id" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] id not found")
|
||||
if not "version" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] version not found")
|
||||
if not "name" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] name not found")
|
||||
if not "description" in manifest["app"]:
|
||||
exit_with_error("Invalid manifest format: [app] description not found")
|
||||
# [author]
|
||||
if not "author" in manifest:
|
||||
exit_with_error("Invalid manifest format: [author] not found")
|
||||
if not "name" in manifest["author"]:
|
||||
exit_with_error("Invalid manifest format: [author] name not found")
|
||||
if not "website" in manifest["author"]:
|
||||
exit_with_error("Invalid manifest format: [author] website not found")
|
||||
|
||||
def is_valid_manifest_platform(manifest, platform):
|
||||
manifest_platforms = manifest["target"]["platforms"].split(",")
|
||||
return platform in manifest_platforms
|
||||
|
||||
def validate_manifest_platform(manifest, platform):
|
||||
if not is_valid_manifest_platform(manifest, platform):
|
||||
exit_with_error(f"Platform {platform} is not available in the manifest.")
|
||||
|
||||
def get_manifest_target_platforms(manifest, requested_platform):
|
||||
if requested_platform == "" or requested_platform is None:
|
||||
return manifest["target"]["platforms"].split(",")
|
||||
else:
|
||||
validate_manifest_platform(manifest, requested_platform)
|
||||
return [requested_platform]
|
||||
|
||||
#endregion Manifest
|
||||
|
||||
#region SDK download
|
||||
|
||||
def sdk_download(version, platform):
|
||||
sdk_root_dir = get_sdk_root_dir(version, platform)
|
||||
os.makedirs(sdk_root_dir, exist_ok=True)
|
||||
sdk_url = get_sdk_url(version, platform)
|
||||
filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip")
|
||||
print(f"Downloading SDK version {version} for {platform}")
|
||||
if download_file(sdk_url, filepath):
|
||||
with zipfile.ZipFile(filepath, "r") as zip_ref:
|
||||
zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK"))
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def sdk_download_all(version, platforms):
|
||||
for platform in platforms:
|
||||
if not sdk_exists(version, platform):
|
||||
if not sdk_download(version, platform):
|
||||
return False
|
||||
else:
|
||||
if verbose:
|
||||
print(f"Using cached download for SDK version {version} and platform {platform}")
|
||||
return True
|
||||
|
||||
#endregion SDK download
|
||||
|
||||
#region Building
|
||||
|
||||
def get_cmake_path(platform):
|
||||
return os.path.join("build", f"cmake-build-{platform}")
|
||||
|
||||
def find_elf_file(platform):
|
||||
cmake_dir = get_cmake_path(platform)
|
||||
if os.path.exists(cmake_dir):
|
||||
for file in os.listdir(cmake_dir):
|
||||
if file.endswith(".app.elf"):
|
||||
return os.path.join(cmake_dir, file)
|
||||
return None
|
||||
|
||||
def build_all(version, platforms, skip_build):
|
||||
for platform in platforms:
|
||||
# First build command must be "idf.py build", otherwise it fails to execute "idf.py elf"
|
||||
# We check if the ELF file exists and run the correct command
|
||||
# This can lead to code caching issues, so sometimes a clean build is required
|
||||
if find_elf_file(platform) is None:
|
||||
if not build_first(version, platform, skip_build):
|
||||
break
|
||||
else:
|
||||
if not build_consecutively(version, platform, skip_build):
|
||||
break
|
||||
|
||||
def wait_for_build(process, platform):
|
||||
buffer = []
|
||||
os.set_blocking(process.stdout.fileno(), False)
|
||||
while process.poll() is None:
|
||||
for i in spinner_pattern:
|
||||
time.sleep(0.1)
|
||||
progress_text = f"Building for {platform} {shell_color_cyan}" + str(i) + shell_color_reset
|
||||
sys.stdout.write(progress_text + "\r")
|
||||
while True:
|
||||
line = process.stdout.readline()
|
||||
decoded_line = line.decode("UTF-8")
|
||||
if decoded_line != "":
|
||||
buffer.append(decoded_line)
|
||||
else:
|
||||
break
|
||||
return buffer
|
||||
|
||||
# The first build must call "idf.py build" and consecutive builds must call "idf.py elf" as it finishes faster.
|
||||
# The problem is that the "idf.py build" always results in an error, even though the elf file is created.
|
||||
# The solution is to suppress the error if we find that the elf file was created.
|
||||
def build_first(version, platform, skip_build):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
if verbose:
|
||||
print(f"Using SDK at {sdk_dir}")
|
||||
os.environ["TACTILITY_SDK_PATH"] = sdk_dir
|
||||
sdkconfig_path = os.path.join(ttbuild_path, f"sdkconfig.app.{platform}")
|
||||
os.system(f"cp {sdkconfig_path} sdkconfig")
|
||||
elf_path = find_elf_file(platform)
|
||||
# Remove previous elf file: re-creation of the file is used to measure if the build succeeded,
|
||||
# as the actual build job will always fail due to technical issues with the elf cmake script
|
||||
if elf_path is not None:
|
||||
os.remove(elf_path)
|
||||
if skip_build:
|
||||
return True
|
||||
print("Building first build")
|
||||
cmake_path = get_cmake_path(platform)
|
||||
with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process:
|
||||
build_output = wait_for_build(process, platform)
|
||||
# The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case
|
||||
if process.returncode == 0:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
else:
|
||||
if find_elf_file(platform) is None:
|
||||
for line in build_output:
|
||||
print(line, end="")
|
||||
print(f"{shell_color_red}Building for {platform} failed ❌{shell_color_reset}")
|
||||
return False
|
||||
else:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
|
||||
def build_consecutively(version, platform, skip_build):
|
||||
sdk_dir = get_sdk_dir(version, platform)
|
||||
if verbose:
|
||||
print(f"Using SDK at {sdk_dir}")
|
||||
os.environ["TACTILITY_SDK_PATH"] = sdk_dir
|
||||
sdkconfig_path = os.path.join(ttbuild_path, f"sdkconfig.app.{platform}")
|
||||
os.system(f"cp {sdkconfig_path} sdkconfig")
|
||||
if skip_build:
|
||||
return True
|
||||
cmake_path = get_cmake_path(platform)
|
||||
with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as process:
|
||||
build_output = wait_for_build(process, platform)
|
||||
if process.returncode == 0:
|
||||
print(f"{shell_color_green}Building for {platform} ✅{shell_color_reset}")
|
||||
return True
|
||||
else:
|
||||
for line in build_output:
|
||||
print(line, end="")
|
||||
print(f"{shell_color_red}Building for {platform} failed ❌{shell_color_reset}")
|
||||
return False
|
||||
|
||||
#endregion Building
|
||||
|
||||
#region Packaging
|
||||
|
||||
def package_intermediate_manifest(target_path):
|
||||
if not os.path.isfile("manifest.properties"):
|
||||
print_error("manifest.properties not found")
|
||||
return
|
||||
shutil.copy("manifest.properties", os.path.join(target_path, "manifest.properties"))
|
||||
|
||||
def package_intermediate_binaries(target_path, platforms):
|
||||
elf_dir = os.path.join(target_path, "elf")
|
||||
os.makedirs(elf_dir, exist_ok=True)
|
||||
for platform in platforms:
|
||||
elf_path = find_elf_file(platform)
|
||||
if elf_path is None:
|
||||
print_error(f"ELF file not found at {elf_path}")
|
||||
return
|
||||
shutil.copy(elf_path, os.path.join(elf_dir, f"{platform}.elf"))
|
||||
|
||||
def package_intermediate_assets(target_path):
|
||||
if os.path.isdir("assets"):
|
||||
shutil.copytree("assets", os.path.join(target_path, "assets"), dirs_exist_ok=True)
|
||||
|
||||
def package_intermediate(platforms):
|
||||
target_path = os.path.join("build", "package-intermediate")
|
||||
if os.path.isdir(target_path):
|
||||
shutil.rmtree(target_path)
|
||||
os.makedirs(target_path, exist_ok=True)
|
||||
package_intermediate_manifest(target_path)
|
||||
package_intermediate_binaries(target_path, platforms)
|
||||
package_intermediate_assets(target_path)
|
||||
|
||||
def package_name(platforms):
|
||||
elf_path = find_elf_file(platforms[0])
|
||||
elf_base_name = os.path.basename(elf_path).removesuffix(".app.elf")
|
||||
return os.path.join("build", f"{elf_base_name}.app")
|
||||
|
||||
def package_all(platforms):
|
||||
print("Packaging app")
|
||||
package_intermediate(platforms)
|
||||
# Create build/something.app
|
||||
tar_path = package_name(platforms)
|
||||
tar = tarfile.open(tar_path, mode="w", format=tarfile.USTAR_FORMAT)
|
||||
tar.add(os.path.join("build", "package-intermediate"), arcname="")
|
||||
tar.close()
|
||||
|
||||
#endregion Packaging
|
||||
|
||||
def setup_environment():
|
||||
global ttbuild_path
|
||||
os.makedirs(ttbuild_path, exist_ok=True)
|
||||
|
||||
def build_action(manifest, platform_arg):
|
||||
# Environment validation
|
||||
validate_environment()
|
||||
platforms_to_build = get_manifest_target_platforms(manifest, platform_arg)
|
||||
if not use_local_sdk:
|
||||
if should_fetch_sdkconfig_files(platforms_to_build):
|
||||
fetch_sdkconfig_files(platforms_to_build)
|
||||
sdk_json = read_sdk_json()
|
||||
validate_self(sdk_json)
|
||||
if not "versions" in sdk_json:
|
||||
exit_with_error("Version data not found in sdk.json")
|
||||
# Build
|
||||
sdk_version = manifest["target"]["sdk"]
|
||||
if not use_local_sdk:
|
||||
validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build)
|
||||
if not sdk_download_all(sdk_version, platforms_to_build):
|
||||
exit_with_error("Failed to download one or more SDKs")
|
||||
build_all(sdk_version, platforms_to_build, skip_build) # Environment validation
|
||||
if not skip_build:
|
||||
package_all(platforms_to_build)
|
||||
|
||||
def clean_action():
|
||||
if os.path.exists("build"):
|
||||
print(f"Removing build/")
|
||||
shutil.rmtree("build")
|
||||
else:
|
||||
print("Nothing to clean")
|
||||
|
||||
def clear_cache_action():
|
||||
if os.path.exists(ttbuild_path):
|
||||
print(f"Removing {ttbuild_path}/")
|
||||
shutil.rmtree(ttbuild_path)
|
||||
else:
|
||||
print("Nothing to clear")
|
||||
|
||||
def update_self_action():
|
||||
sdk_json = read_sdk_json()
|
||||
tool_download_url = sdk_json["toolDownloadUrl"]
|
||||
if download_file(tool_download_url, "tactility.py"):
|
||||
print("Updated")
|
||||
else:
|
||||
exit_with_error("Update failed")
|
||||
|
||||
def get_device_info(ip):
|
||||
print(f"Getting device info from {ip}")
|
||||
url = get_url(ip, "/info")
|
||||
try:
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
print_error("Run failed")
|
||||
else:
|
||||
print(response.json())
|
||||
print(f"{shell_color_green}Run successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
|
||||
def run_action(manifest, ip):
|
||||
app_id = manifest["app"]["id"]
|
||||
print(f"Running {app_id} on {ip}")
|
||||
url = get_url(ip, "/app/run")
|
||||
params = {'id': app_id}
|
||||
try:
|
||||
response = requests.post(url, params=params)
|
||||
if response.status_code != 200:
|
||||
print_error("Run failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Run successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
|
||||
def install_action(ip, platforms):
|
||||
for platform in platforms:
|
||||
elf_path = find_elf_file(platform)
|
||||
if elf_path is None:
|
||||
exit_with_error(f"ELF file not built for {platform}")
|
||||
package_path = package_name(platforms)
|
||||
print(f"Installing {package_path} to {ip}")
|
||||
url = get_url(ip, "/app/install")
|
||||
try:
|
||||
# Prepare multipart form data
|
||||
with open(package_path, 'rb') as file:
|
||||
files = {
|
||||
'elf': file
|
||||
}
|
||||
response = requests.put(url, files=files)
|
||||
if response.status_code != 200:
|
||||
print_error("Install failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Installation successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print_error(f"Installation failed: {e}")
|
||||
except IOError as e:
|
||||
print_error(f"File error: {e}")
|
||||
|
||||
def uninstall_action(manifest, ip):
|
||||
app_id = manifest["app"]["id"]
|
||||
print(f"Uninstalling {app_id} on {ip}")
|
||||
url = get_url(ip, "/app/uninstall")
|
||||
params = {'id': app_id}
|
||||
try:
|
||||
response = requests.put(url, params=params)
|
||||
if response.status_code != 200:
|
||||
print_error("Uninstall failed")
|
||||
else:
|
||||
print(f"{shell_color_green}Uninstall successful ✅{shell_color_reset}")
|
||||
except requests.RequestException as e:
|
||||
print(f"Request failed: {e}")
|
||||
#region Main
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Tactility Build System v{ttbuild_version}")
|
||||
if "--help" in sys.argv:
|
||||
print_help()
|
||||
sys.exit()
|
||||
# Argument validation
|
||||
if len(sys.argv) == 1:
|
||||
print_help()
|
||||
sys.exit()
|
||||
action_arg = sys.argv[1]
|
||||
verbose = "--verbose" in sys.argv
|
||||
skip_build = "--skip-build" in sys.argv
|
||||
use_local_sdk = "--local-sdk" in sys.argv
|
||||
# Environment setup
|
||||
setup_environment()
|
||||
if not os.path.isfile("manifest.properties"):
|
||||
exit_with_error("manifest.properties not found")
|
||||
manifest = read_manifest()
|
||||
validate_manifest(manifest)
|
||||
all_platform_targets = manifest["target"]["platforms"].split(",")
|
||||
# Update SDK cache (sdk.json)
|
||||
if should_update_sdk_json() and not update_sdk_json():
|
||||
exit_with_error("Failed to retrieve SDK info")
|
||||
# Actions
|
||||
if action_arg == "build":
|
||||
if len(sys.argv) < 2:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
if len(sys.argv) > 2:
|
||||
platform = sys.argv[2]
|
||||
build_action(manifest, platform)
|
||||
elif action_arg == "clean":
|
||||
clean_action()
|
||||
elif action_arg == "clearcache":
|
||||
clear_cache_action()
|
||||
elif action_arg == "updateself":
|
||||
update_self_action()
|
||||
elif action_arg == "run":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
run_action(manifest, sys.argv[2])
|
||||
elif action_arg == "install":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
platforms_to_install = all_platform_targets
|
||||
if len(sys.argv) >= 4:
|
||||
platform = sys.argv[3]
|
||||
platforms_to_install = [platform]
|
||||
install_action(sys.argv[2], platforms_to_install)
|
||||
elif action_arg == "uninstall":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
uninstall_action(manifest, sys.argv[2])
|
||||
elif action_arg == "bir" or action_arg == "brrr":
|
||||
if len(sys.argv) < 3:
|
||||
print_help()
|
||||
exit_with_error("Commandline parameter missing")
|
||||
platform = None
|
||||
platforms_to_install = all_platform_targets
|
||||
if len(sys.argv) >= 4:
|
||||
platform = sys.argv[3]
|
||||
platforms_to_install = [platform]
|
||||
build_action(manifest, platform)
|
||||
install_action(sys.argv[2], platforms_to_install)
|
||||
run_action(manifest, sys.argv[2])
|
||||
else:
|
||||
print_help()
|
||||
exit_with_error("Unknown commandline parameter")
|
||||
|
||||
#endregion Main
|
||||
@ -12,5 +12,5 @@ endif()
|
||||
include("${TACTILITY_SDK_PATH}/TactilitySDK.cmake")
|
||||
set(EXTRA_COMPONENT_DIRS ${TACTILITY_SDK_PATH})
|
||||
|
||||
project(Calculator)
|
||||
tactility_project(Calculator)
|
||||
project(RadioSet)
|
||||
tactility_project(RadioSet)
|
||||
@ -4,3 +4,5 @@ idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
REQUIRES TactilitySDK
|
||||
)
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-error=uninitialized -Wno-error=maybe-uninitialized)
|
||||
156
ExternalApps/RadioSet/main/Source/LinkedList.h
Normal file
@ -0,0 +1,156 @@
|
||||
#pragma once
|
||||
|
||||
template <typename DataType>
|
||||
class LinkedList {
|
||||
|
||||
struct Node {
|
||||
DataType data;
|
||||
Node* next;
|
||||
Node* previous;
|
||||
|
||||
Node(DataType data, Node* next, Node* previous):
|
||||
data(data),
|
||||
next(next),
|
||||
previous(previous)
|
||||
{}
|
||||
};
|
||||
|
||||
int count = 0;
|
||||
Node* head = nullptr;
|
||||
Node* tail = nullptr;
|
||||
|
||||
public:
|
||||
class Iterator {
|
||||
Node *node = nullptr;
|
||||
public:
|
||||
Iterator(Node* node)
|
||||
: node(node) {}
|
||||
|
||||
bool advance(size_t n) {
|
||||
size_t i = 0;
|
||||
if (n == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; node && (i < n); ++i) {
|
||||
node = node->next;
|
||||
}
|
||||
return (i > 0);
|
||||
}
|
||||
|
||||
DataType& operator* ()
|
||||
{
|
||||
return node->data;
|
||||
}
|
||||
|
||||
DataType* operator-> ()
|
||||
{
|
||||
return &(node->data);
|
||||
}
|
||||
|
||||
Iterator operator++ (int) {
|
||||
assert(advance(1));
|
||||
Iterator i(node);
|
||||
return i;
|
||||
}
|
||||
|
||||
bool operator==(const Iterator& right) const {
|
||||
return node == right.node;
|
||||
}
|
||||
|
||||
bool operator!=(const Iterator& right) const {
|
||||
return node != right.node;
|
||||
}
|
||||
};
|
||||
|
||||
void pushFront(DataType data) {
|
||||
auto* new_node = new Node(data, head, nullptr);
|
||||
|
||||
if (head != nullptr) {
|
||||
head->previous = new_node;
|
||||
}
|
||||
|
||||
if (tail == nullptr) {
|
||||
tail = new_node;
|
||||
}
|
||||
|
||||
head = new_node;
|
||||
count++;
|
||||
}
|
||||
|
||||
void pushBack(DataType data) {
|
||||
auto* new_node = new Node(data, nullptr, tail);
|
||||
|
||||
if (head == nullptr) {
|
||||
head = new_node;
|
||||
}
|
||||
|
||||
if (tail != nullptr) {
|
||||
tail->next = new_node;
|
||||
}
|
||||
|
||||
tail = new_node;
|
||||
count++;
|
||||
}
|
||||
|
||||
void popFront() {
|
||||
if (head != nullptr) {
|
||||
bool is_last_node = (head == tail);
|
||||
Node* node_to_delete = head;
|
||||
head = node_to_delete->next;
|
||||
if (is_last_node) {
|
||||
tail = nullptr;
|
||||
}
|
||||
delete node_to_delete;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
void popBack() {
|
||||
if (tail != nullptr) {
|
||||
bool is_last_node = (head == tail);
|
||||
Node* node_to_delete = tail;
|
||||
tail = node_to_delete->previous;
|
||||
if (is_last_node) {
|
||||
head = nullptr;
|
||||
}
|
||||
delete node_to_delete;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
DataType back() const {
|
||||
assert(tail != nullptr);
|
||||
return tail->data;
|
||||
}
|
||||
|
||||
DataType front() const {
|
||||
assert(head != nullptr);
|
||||
return head->data;
|
||||
}
|
||||
|
||||
Iterator begin() const {
|
||||
return Iterator(head);
|
||||
}
|
||||
|
||||
Iterator end() const {
|
||||
return Iterator(nullptr);
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return head == nullptr;
|
||||
}
|
||||
|
||||
int size() const { return count; }
|
||||
|
||||
DataType operator [] (int i) const {
|
||||
auto iter = begin();
|
||||
assert(iter.advance(i));
|
||||
return *iter;
|
||||
}
|
||||
DataType& operator [] (int i) {
|
||||
auto iter = begin();
|
||||
assert(iter.advance(i));
|
||||
return *iter;
|
||||
}
|
||||
};
|
||||
37
ExternalApps/RadioSet/main/Source/Preset.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_hal_radio.h>
|
||||
|
||||
#include "Str.h"
|
||||
#include "LinkedList.h"
|
||||
|
||||
class Preset {
|
||||
public:
|
||||
struct PresetItem {
|
||||
RadioParameter parameter;
|
||||
float value;
|
||||
};
|
||||
|
||||
Str name;
|
||||
Modulation modulation;
|
||||
LinkedList<PresetItem> items;
|
||||
|
||||
Preset(const char* const name, Modulation modulation)
|
||||
: name(name)
|
||||
, modulation(modulation)
|
||||
{}
|
||||
|
||||
virtual ~Preset() = default;
|
||||
|
||||
void addParameter(RadioParameter parameter, float value) {
|
||||
items.pushBack({parameter, value});
|
||||
}
|
||||
|
||||
LinkedList<PresetItem>::Iterator begin() {
|
||||
return items.begin();
|
||||
}
|
||||
|
||||
LinkedList<PresetItem>::Iterator end() {
|
||||
return items.end();
|
||||
}
|
||||
};
|
||||
1095
ExternalApps/RadioSet/main/Source/RadioSet.cpp
Normal file
24
ExternalApps/RadioSet/main/Source/RadioSet.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_app.h"
|
||||
#include "tt_hal_radio.h"
|
||||
#include <lvgl.h>
|
||||
|
||||
class TermView;
|
||||
class SettingsView;
|
||||
|
||||
class RadioSet {
|
||||
lv_obj_t* mainView = nullptr;
|
||||
lv_obj_t* uiDropDownMenu = nullptr;
|
||||
lv_obj_t* progressBar = nullptr;
|
||||
lv_obj_t* progressText = nullptr;
|
||||
|
||||
TermView* termView = nullptr;
|
||||
SettingsView* settingsView = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
~RadioSet();
|
||||
|
||||
void onShow(AppHandle context, lv_obj_t* parent);
|
||||
};
|
||||
@ -1,16 +1,16 @@
|
||||
#include <tt_app.h>
|
||||
#include "Calculator.h"
|
||||
#include "RadioSet.h"
|
||||
|
||||
static void onShow(AppHandle appHandle, void* data, lv_obj_t* parent) {
|
||||
static_cast<Calculator*>(data)->onShow(appHandle, parent);
|
||||
static_cast<RadioSet*>(data)->onShow(appHandle, parent);
|
||||
}
|
||||
|
||||
static void* createApp() {
|
||||
return new Calculator();
|
||||
return new RadioSet();
|
||||
}
|
||||
|
||||
static void destroyApp(void* app) {
|
||||
delete static_cast<Calculator*>(app);
|
||||
delete static_cast<RadioSet*>(app);
|
||||
}
|
||||
|
||||
ExternalAppManifest manifest = {
|
||||
48
ExternalApps/RadioSet/main/Source/soft-fp/adddf3.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* Software floating-point emulation.
|
||||
Return a + b
|
||||
Copyright (C) 1997,1999, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
DFtype __adddf3(DFtype a, DFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R);
|
||||
DFtype r;
|
||||
|
||||
FP_INIT_ROUNDMODE;
|
||||
FP_UNPACK_SEMIRAW_D(A, a);
|
||||
FP_UNPACK_SEMIRAW_D(B, b);
|
||||
FP_ADD_D(R, A, B);
|
||||
FP_PACK_SEMIRAW_D(r, R);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
48
ExternalApps/RadioSet/main/Source/soft-fp/addsf3.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* Software floating-point emulation.
|
||||
Return a + b
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
SFtype __addsf3(SFtype a, SFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A); FP_DECL_S(B); FP_DECL_S(R);
|
||||
SFtype r;
|
||||
|
||||
FP_INIT_ROUNDMODE;
|
||||
FP_UNPACK_SEMIRAW_S(A, a);
|
||||
FP_UNPACK_SEMIRAW_S(B, b);
|
||||
FP_ADD_S(R, A, B);
|
||||
FP_PACK_SEMIRAW_S(r, R);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
53
ExternalApps/RadioSet/main/Source/soft-fp/clzsi2.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __clzsi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
//
|
||||
// Ported by wsyeo for 8267 compatibility.
|
||||
//
|
||||
|
||||
// Returns: the number of leading 0-bits
|
||||
|
||||
// Precondition: a != 0
|
||||
|
||||
unsigned int __clzsi2(unsigned int a)
|
||||
{
|
||||
unsigned int x = a;
|
||||
int t = ((x & 0xFFFF0000) == 0) << 4; // if (x is small) t = 16 else 0
|
||||
x >>= 16 - t; // x = [0 - 0xFFFF]
|
||||
unsigned int r = t; // r = [0, 16]
|
||||
// return r + clz(x)
|
||||
t = ((x & 0xFF00) == 0) << 3;
|
||||
x >>= 8 - t; // x = [0 - 0xFF]
|
||||
r += t; // r = [0, 8, 16, 24]
|
||||
// return r + clz(x)
|
||||
t = ((x & 0xF0) == 0) << 2;
|
||||
x >>= 4 - t; // x = [0 - 0xF]
|
||||
r += t; // r = [0, 4, 8, 12, 16, 20, 24, 28]
|
||||
// return r + clz(x)
|
||||
t = ((x & 0xC) == 0) << 1;
|
||||
x >>= 2 - t; // x = [0 - 3]
|
||||
r += t; // r = [0 - 30] and is even
|
||||
// return r + clz(x)
|
||||
// switch (x)
|
||||
// {
|
||||
// case 0:
|
||||
// return r + 2;
|
||||
// case 1:
|
||||
// return r + 1;
|
||||
// case 2:
|
||||
// case 3:
|
||||
// return r;
|
||||
// }
|
||||
return r + ((2 - x) & -((x & 2) == 0));
|
||||
}
|
||||
48
ExternalApps/RadioSet/main/Source/soft-fp/divdf3.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* Software floating-point emulation.
|
||||
Return a / b
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
DFtype __divdf3(DFtype a, DFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A); FP_DECL_D(B); FP_DECL_D(R);
|
||||
DFtype r;
|
||||
|
||||
FP_INIT_ROUNDMODE;
|
||||
FP_UNPACK_D(A, a);
|
||||
FP_UNPACK_D(B, b);
|
||||
FP_DIV_D(R, A, B);
|
||||
FP_PACK_D(r, R);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
48
ExternalApps/RadioSet/main/Source/soft-fp/divsf3.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* Software floating-point emulation.
|
||||
Return a / b
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
SFtype __divsf3(SFtype a, SFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A); FP_DECL_S(B); FP_DECL_S(R);
|
||||
SFtype r;
|
||||
|
||||
FP_INIT_ROUNDMODE;
|
||||
FP_UNPACK_S(A, a);
|
||||
FP_UNPACK_S(B, b);
|
||||
FP_DIV_S(R, A, B);
|
||||
FP_PACK_S(r, R);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
264
ExternalApps/RadioSet/main/Source/soft-fp/double.h
Normal file
@ -0,0 +1,264 @@
|
||||
/* Software floating-point emulation.
|
||||
Definitions for IEEE Double Precision
|
||||
Copyright (C) 1997, 1998, 1999, 2006, 2007, 2008, 2009, 2012
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com),
|
||||
Jakub Jelinek (jj@ultra.linux.cz),
|
||||
David S. Miller (davem@redhat.com) and
|
||||
Peter Maydell (pmaydell@chiark.greenend.org.uk).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 32
|
||||
#error "Here's a nickel kid. Go buy yourself a real computer."
|
||||
#endif
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 64
|
||||
#define _FP_FRACTBITS_D (2 * _FP_W_TYPE_SIZE)
|
||||
#else
|
||||
#define _FP_FRACTBITS_D _FP_W_TYPE_SIZE
|
||||
#endif
|
||||
|
||||
#define _FP_FRACBITS_D 53
|
||||
#define _FP_FRACXBITS_D (_FP_FRACTBITS_D - _FP_FRACBITS_D)
|
||||
#define _FP_WFRACBITS_D (_FP_WORKBITS + _FP_FRACBITS_D)
|
||||
#define _FP_WFRACXBITS_D (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
|
||||
#define _FP_EXPBITS_D 11
|
||||
#define _FP_EXPBIAS_D 1023
|
||||
#define _FP_EXPMAX_D 2047
|
||||
|
||||
#define _FP_QNANBIT_D \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_QNANBIT_SH_D \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_IMPLBIT_D \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_IMPLBIT_SH_D \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_OVERFLOW_D \
|
||||
((_FP_W_TYPE)1 << _FP_WFRACBITS_D % _FP_W_TYPE_SIZE)
|
||||
|
||||
typedef float DFtype __attribute__((mode(DF)));
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 64
|
||||
|
||||
union _FP_UNION_D
|
||||
{
|
||||
DFtype flt;
|
||||
struct _FP_STRUCT_LAYOUT {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned sign : 1;
|
||||
unsigned exp : _FP_EXPBITS_D;
|
||||
unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
|
||||
unsigned frac0 : _FP_W_TYPE_SIZE;
|
||||
#else
|
||||
unsigned frac0 : _FP_W_TYPE_SIZE;
|
||||
unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
|
||||
unsigned exp : _FP_EXPBITS_D;
|
||||
unsigned sign : 1;
|
||||
#endif
|
||||
} bits __attribute__((packed));
|
||||
};
|
||||
|
||||
#define FP_DECL_D(X) _FP_DECL(2,X)
|
||||
#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_2(D,X,val)
|
||||
#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_2_P(D,X,val)
|
||||
#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_2(D,val,X)
|
||||
#define FP_PACK_RAW_DP(val,X) \
|
||||
do { \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_2_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_D(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_2(D,X,val); \
|
||||
_FP_UNPACK_CANONICAL(D,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_DP(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_2_P(D,X,val); \
|
||||
_FP_UNPACK_CANONICAL(D,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_D(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_2(D,X,val); \
|
||||
_FP_UNPACK_SEMIRAW(D,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_DP(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_2_P(D,X,val); \
|
||||
_FP_UNPACK_SEMIRAW(D,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_D(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(D,2,X); \
|
||||
_FP_PACK_RAW_2(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_DP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(D,2,X); \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_2_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_D(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(D,2,X); \
|
||||
_FP_PACK_RAW_2(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_DP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(D,2,X); \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_2_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,2,X)
|
||||
#define FP_NEG_D(R,X) _FP_NEG(D,2,R,X)
|
||||
#define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
|
||||
#define FP_SUB_D(R,X,Y) _FP_SUB(D,2,R,X,Y)
|
||||
#define FP_MUL_D(R,X,Y) _FP_MUL(D,2,R,X,Y)
|
||||
#define FP_DIV_D(R,X,Y) _FP_DIV(D,2,R,X,Y)
|
||||
#define FP_SQRT_D(R,X) _FP_SQRT(D,2,R,X)
|
||||
#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_2(R,S,T,X,Q)
|
||||
|
||||
#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,2,r,X,Y,un)
|
||||
#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,2,r,X,Y)
|
||||
#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,2,r,X,Y)
|
||||
|
||||
#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,2,r,X,rsz,rsg)
|
||||
#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,2,X,r,rs,rt)
|
||||
|
||||
#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_2(X)
|
||||
#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_2(X)
|
||||
|
||||
#else
|
||||
|
||||
union _FP_UNION_D
|
||||
{
|
||||
DFtype flt;
|
||||
struct _FP_STRUCT_LAYOUT {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned sign : 1;
|
||||
unsigned exp : _FP_EXPBITS_D;
|
||||
_FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
|
||||
#else
|
||||
_FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
|
||||
unsigned exp : _FP_EXPBITS_D;
|
||||
unsigned sign : 1;
|
||||
#endif
|
||||
} bits __attribute__((packed));
|
||||
};
|
||||
|
||||
#define FP_DECL_D(X) _FP_DECL(1,X)
|
||||
#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_1(D,X,val)
|
||||
#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_1_P(D,X,val)
|
||||
#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_1(D,val,X)
|
||||
#define FP_PACK_RAW_DP(val,X) \
|
||||
do { \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_1_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_D(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_1(D,X,val); \
|
||||
_FP_UNPACK_CANONICAL(D,1,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_DP(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_1_P(D,X,val); \
|
||||
_FP_UNPACK_CANONICAL(D,1,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_D(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_1(D,X,val); \
|
||||
_FP_UNPACK_SEMIRAW(D,1,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_DP(X,val) \
|
||||
do { \
|
||||
_FP_UNPACK_RAW_1_P(D,X,val); \
|
||||
_FP_UNPACK_SEMIRAW(D,1,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_D(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(D,1,X); \
|
||||
_FP_PACK_RAW_1(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_DP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(D,1,X); \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_1_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_D(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(D,1,X); \
|
||||
_FP_PACK_RAW_1(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_DP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(D,1,X); \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
_FP_PACK_RAW_1_P(D,val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,1,X)
|
||||
#define FP_NEG_D(R,X) _FP_NEG(D,1,R,X)
|
||||
#define FP_ADD_D(R,X,Y) _FP_ADD(D,1,R,X,Y)
|
||||
#define FP_SUB_D(R,X,Y) _FP_SUB(D,1,R,X,Y)
|
||||
#define FP_MUL_D(R,X,Y) _FP_MUL(D,1,R,X,Y)
|
||||
#define FP_DIV_D(R,X,Y) _FP_DIV(D,1,R,X,Y)
|
||||
#define FP_SQRT_D(R,X) _FP_SQRT(D,1,R,X)
|
||||
#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
|
||||
|
||||
/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
|
||||
the target machine. */
|
||||
|
||||
#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,1,r,X,Y,un)
|
||||
#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,1,r,X,Y)
|
||||
#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,1,r,X,Y)
|
||||
|
||||
#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,1,r,X,rsz,rsg)
|
||||
#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,1,X,r,rs,rt)
|
||||
|
||||
#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_1(X)
|
||||
#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_1(X)
|
||||
|
||||
#endif /* W_TYPE_SIZE < 64 */
|
||||
50
ExternalApps/RadioSet/main/Source/soft-fp/eqdf2.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* Software floating-point emulation.
|
||||
Return 0 iff a == b, 1 otherwise
|
||||
Copyright (C) 1997,1999,2006,2007 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
CMPtype __eqdf2(DFtype a, DFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A); FP_DECL_D(B);
|
||||
CMPtype r;
|
||||
|
||||
FP_UNPACK_RAW_D(A, a);
|
||||
FP_UNPACK_RAW_D(B, b);
|
||||
FP_CMP_EQ_D(r, A, B);
|
||||
if (r && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B)))
|
||||
FP_SET_EXCEPTION(FP_EX_INVALID);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
strong_alias(__eqdf2, __nedf2);
|
||||
50
ExternalApps/RadioSet/main/Source/soft-fp/eqsf2.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* Software floating-point emulation.
|
||||
Return 0 iff a == b, 1 otherwise
|
||||
Copyright (C) 1997,1999,2006,2007 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
CMPtype __eqsf2(SFtype a, SFtype b)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A); FP_DECL_S(B);
|
||||
CMPtype r;
|
||||
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
FP_UNPACK_RAW_S(B, b);
|
||||
FP_CMP_EQ_S(r, A, B);
|
||||
if (r && (FP_ISSIGNAN_S(A) || FP_ISSIGNAN_S(B)))
|
||||
FP_SET_EXCEPTION(FP_EX_INVALID);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
strong_alias(__eqsf2, __nesf2);
|
||||
430
ExternalApps/RadioSet/main/Source/soft-fp/extended.h
Normal file
@ -0,0 +1,430 @@
|
||||
/* Software floating-point emulation.
|
||||
Definitions for IEEE Extended Precision.
|
||||
Copyright (C) 1999,2006,2007,2012 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 32
|
||||
#error "Here's a nickel, kid. Go buy yourself a real computer."
|
||||
#endif
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 64
|
||||
#define _FP_FRACTBITS_E (4*_FP_W_TYPE_SIZE)
|
||||
#else
|
||||
#define _FP_FRACTBITS_E (2*_FP_W_TYPE_SIZE)
|
||||
#endif
|
||||
|
||||
#define _FP_FRACBITS_E 64
|
||||
#define _FP_FRACXBITS_E (_FP_FRACTBITS_E - _FP_FRACBITS_E)
|
||||
#define _FP_WFRACBITS_E (_FP_WORKBITS + _FP_FRACBITS_E)
|
||||
#define _FP_WFRACXBITS_E (_FP_FRACTBITS_E - _FP_WFRACBITS_E)
|
||||
#define _FP_EXPBITS_E 15
|
||||
#define _FP_EXPBIAS_E 16383
|
||||
#define _FP_EXPMAX_E 32767
|
||||
|
||||
#define _FP_QNANBIT_E \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_QNANBIT_SH_E \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_IMPLBIT_E \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_IMPLBIT_SH_E \
|
||||
((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
|
||||
#define _FP_OVERFLOW_E \
|
||||
((_FP_W_TYPE)1 << (_FP_WFRACBITS_E % _FP_W_TYPE_SIZE))
|
||||
|
||||
typedef float XFtype __attribute__((mode(XF)));
|
||||
|
||||
#if _FP_W_TYPE_SIZE < 64
|
||||
|
||||
union _FP_UNION_E
|
||||
{
|
||||
XFtype flt;
|
||||
struct _FP_STRUCT_LAYOUT
|
||||
{
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned long pad1 : _FP_W_TYPE_SIZE;
|
||||
unsigned long pad2 : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
|
||||
unsigned long sign : 1;
|
||||
unsigned long exp : _FP_EXPBITS_E;
|
||||
unsigned long frac1 : _FP_W_TYPE_SIZE;
|
||||
unsigned long frac0 : _FP_W_TYPE_SIZE;
|
||||
#else
|
||||
unsigned long frac0 : _FP_W_TYPE_SIZE;
|
||||
unsigned long frac1 : _FP_W_TYPE_SIZE;
|
||||
unsigned exp : _FP_EXPBITS_E;
|
||||
unsigned sign : 1;
|
||||
#endif /* not bigendian */
|
||||
} bits __attribute__((packed));
|
||||
};
|
||||
|
||||
|
||||
#define FP_DECL_E(X) _FP_DECL(4,X)
|
||||
|
||||
#define FP_UNPACK_RAW_E(X, val) \
|
||||
do { \
|
||||
union _FP_UNION_E _flo; _flo.flt = (val); \
|
||||
\
|
||||
X##_f[2] = 0; X##_f[3] = 0; \
|
||||
X##_f[0] = _flo.bits.frac0; \
|
||||
X##_f[1] = _flo.bits.frac1; \
|
||||
X##_e = _flo.bits.exp; \
|
||||
X##_s = _flo.bits.sign; \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_RAW_EP(X, val) \
|
||||
do { \
|
||||
union _FP_UNION_E *_flo = \
|
||||
(union _FP_UNION_E *)(val); \
|
||||
\
|
||||
X##_f[2] = 0; X##_f[3] = 0; \
|
||||
X##_f[0] = _flo->bits.frac0; \
|
||||
X##_f[1] = _flo->bits.frac1; \
|
||||
X##_e = _flo->bits.exp; \
|
||||
X##_s = _flo->bits.sign; \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_RAW_E(val, X) \
|
||||
do { \
|
||||
union _FP_UNION_E _flo; \
|
||||
\
|
||||
if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
|
||||
else X##_f[1] &= ~(_FP_IMPLBIT_E); \
|
||||
_flo.bits.frac0 = X##_f[0]; \
|
||||
_flo.bits.frac1 = X##_f[1]; \
|
||||
_flo.bits.exp = X##_e; \
|
||||
_flo.bits.sign = X##_s; \
|
||||
\
|
||||
(val) = _flo.flt; \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_RAW_EP(val, X) \
|
||||
do { \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
{ \
|
||||
union _FP_UNION_E *_flo = \
|
||||
(union _FP_UNION_E *)(val); \
|
||||
\
|
||||
if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
|
||||
else X##_f[1] &= ~(_FP_IMPLBIT_E); \
|
||||
_flo->bits.frac0 = X##_f[0]; \
|
||||
_flo->bits.frac1 = X##_f[1]; \
|
||||
_flo->bits.exp = X##_e; \
|
||||
_flo->bits.sign = X##_s; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_E(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_E(X,val); \
|
||||
_FP_UNPACK_CANONICAL(E,4,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_EP(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_EP(X,val); \
|
||||
_FP_UNPACK_CANONICAL(E,4,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_E(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_E(X,val); \
|
||||
_FP_UNPACK_SEMIRAW(E,4,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_EP(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_EP(X,val); \
|
||||
_FP_UNPACK_SEMIRAW(E,4,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_E(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(E,4,X); \
|
||||
FP_PACK_RAW_E(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_EP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(E,4,X); \
|
||||
FP_PACK_RAW_EP(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_E(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(E,4,X); \
|
||||
FP_PACK_RAW_E(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_EP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(E,4,X); \
|
||||
FP_PACK_RAW_EP(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,4,X)
|
||||
#define FP_NEG_E(R,X) _FP_NEG(E,4,R,X)
|
||||
#define FP_ADD_E(R,X,Y) _FP_ADD(E,4,R,X,Y)
|
||||
#define FP_SUB_E(R,X,Y) _FP_SUB(E,4,R,X,Y)
|
||||
#define FP_MUL_E(R,X,Y) _FP_MUL(E,4,R,X,Y)
|
||||
#define FP_DIV_E(R,X,Y) _FP_DIV(E,4,R,X,Y)
|
||||
#define FP_SQRT_E(R,X) _FP_SQRT(E,4,R,X)
|
||||
|
||||
/*
|
||||
* Square root algorithms:
|
||||
* We have just one right now, maybe Newton approximation
|
||||
* should be added for those machines where division is fast.
|
||||
* This has special _E version because standard _4 square
|
||||
* root would not work (it has to start normally with the
|
||||
* second word and not the first), but as we have to do it
|
||||
* anyway, we optimize it by doing most of the calculations
|
||||
* in two UWtype registers instead of four.
|
||||
*/
|
||||
|
||||
#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
|
||||
do { \
|
||||
q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
|
||||
_FP_FRAC_SRL_4(X, (_FP_WORKBITS)); \
|
||||
while (q) \
|
||||
{ \
|
||||
T##_f[1] = S##_f[1] + q; \
|
||||
if (T##_f[1] <= X##_f[1]) \
|
||||
{ \
|
||||
S##_f[1] = T##_f[1] + q; \
|
||||
X##_f[1] -= T##_f[1]; \
|
||||
R##_f[1] += q; \
|
||||
} \
|
||||
_FP_FRAC_SLL_2(X, 1); \
|
||||
q >>= 1; \
|
||||
} \
|
||||
q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
|
||||
while (q) \
|
||||
{ \
|
||||
T##_f[0] = S##_f[0] + q; \
|
||||
T##_f[1] = S##_f[1]; \
|
||||
if (T##_f[1] < X##_f[1] || \
|
||||
(T##_f[1] == X##_f[1] && \
|
||||
T##_f[0] <= X##_f[0])) \
|
||||
{ \
|
||||
S##_f[0] = T##_f[0] + q; \
|
||||
S##_f[1] += (T##_f[0] > S##_f[0]); \
|
||||
_FP_FRAC_DEC_2(X, T); \
|
||||
R##_f[0] += q; \
|
||||
} \
|
||||
_FP_FRAC_SLL_2(X, 1); \
|
||||
q >>= 1; \
|
||||
} \
|
||||
_FP_FRAC_SLL_4(R, (_FP_WORKBITS)); \
|
||||
if (X##_f[0] | X##_f[1]) \
|
||||
{ \
|
||||
if (S##_f[1] < X##_f[1] || \
|
||||
(S##_f[1] == X##_f[1] && \
|
||||
S##_f[0] < X##_f[0])) \
|
||||
R##_f[0] |= _FP_WORK_ROUND; \
|
||||
R##_f[0] |= _FP_WORK_STICKY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,4,r,X,Y,un)
|
||||
#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,4,r,X,Y)
|
||||
#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,4,r,X,Y)
|
||||
|
||||
#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,4,r,X,rsz,rsg)
|
||||
#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,4,X,r,rs,rt)
|
||||
|
||||
#define _FP_FRAC_HIGH_E(X) (X##_f[2])
|
||||
#define _FP_FRAC_HIGH_RAW_E(X) (X##_f[1])
|
||||
|
||||
#else /* not _FP_W_TYPE_SIZE < 64 */
|
||||
union _FP_UNION_E
|
||||
{
|
||||
XFtype flt;
|
||||
struct _FP_STRUCT_LAYOUT {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
_FP_W_TYPE pad : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
|
||||
unsigned sign : 1;
|
||||
unsigned exp : _FP_EXPBITS_E;
|
||||
_FP_W_TYPE frac : _FP_W_TYPE_SIZE;
|
||||
#else
|
||||
_FP_W_TYPE frac : _FP_W_TYPE_SIZE;
|
||||
unsigned exp : _FP_EXPBITS_E;
|
||||
unsigned sign : 1;
|
||||
#endif
|
||||
} bits;
|
||||
};
|
||||
|
||||
#define FP_DECL_E(X) _FP_DECL(2,X)
|
||||
|
||||
#define FP_UNPACK_RAW_E(X, val) \
|
||||
do { \
|
||||
union _FP_UNION_E _flo; _flo.flt = (val); \
|
||||
\
|
||||
X##_f0 = _flo.bits.frac; \
|
||||
X##_f1 = 0; \
|
||||
X##_e = _flo.bits.exp; \
|
||||
X##_s = _flo.bits.sign; \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_RAW_EP(X, val) \
|
||||
do { \
|
||||
union _FP_UNION_E *_flo = \
|
||||
(union _FP_UNION_E *)(val); \
|
||||
\
|
||||
X##_f0 = _flo->bits.frac; \
|
||||
X##_f1 = 0; \
|
||||
X##_e = _flo->bits.exp; \
|
||||
X##_s = _flo->bits.sign; \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_RAW_E(val, X) \
|
||||
do { \
|
||||
union _FP_UNION_E _flo; \
|
||||
\
|
||||
if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
|
||||
else X##_f0 &= ~(_FP_IMPLBIT_E); \
|
||||
_flo.bits.frac = X##_f0; \
|
||||
_flo.bits.exp = X##_e; \
|
||||
_flo.bits.sign = X##_s; \
|
||||
\
|
||||
(val) = _flo.flt; \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_RAW_EP(fs, val, X) \
|
||||
do { \
|
||||
if (!FP_INHIBIT_RESULTS) \
|
||||
{ \
|
||||
union _FP_UNION_E *_flo = \
|
||||
(union _FP_UNION_E *)(val); \
|
||||
\
|
||||
if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
|
||||
else X##_f0 &= ~(_FP_IMPLBIT_E); \
|
||||
_flo->bits.frac = X##_f0; \
|
||||
_flo->bits.exp = X##_e; \
|
||||
_flo->bits.sign = X##_s; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define FP_UNPACK_E(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_E(X,val); \
|
||||
_FP_UNPACK_CANONICAL(E,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_EP(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_EP(X,val); \
|
||||
_FP_UNPACK_CANONICAL(E,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_E(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_E(X,val); \
|
||||
_FP_UNPACK_SEMIRAW(E,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_UNPACK_SEMIRAW_EP(X,val) \
|
||||
do { \
|
||||
FP_UNPACK_RAW_EP(X,val); \
|
||||
_FP_UNPACK_SEMIRAW(E,2,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_E(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(E,2,X); \
|
||||
FP_PACK_RAW_E(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_EP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_CANONICAL(E,2,X); \
|
||||
FP_PACK_RAW_EP(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_E(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(E,2,X); \
|
||||
FP_PACK_RAW_E(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_PACK_SEMIRAW_EP(val,X) \
|
||||
do { \
|
||||
_FP_PACK_SEMIRAW(E,2,X); \
|
||||
FP_PACK_RAW_EP(val,X); \
|
||||
} while (0)
|
||||
|
||||
#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,2,X)
|
||||
#define FP_NEG_E(R,X) _FP_NEG(E,2,R,X)
|
||||
#define FP_ADD_E(R,X,Y) _FP_ADD(E,2,R,X,Y)
|
||||
#define FP_SUB_E(R,X,Y) _FP_SUB(E,2,R,X,Y)
|
||||
#define FP_MUL_E(R,X,Y) _FP_MUL(E,2,R,X,Y)
|
||||
#define FP_DIV_E(R,X,Y) _FP_DIV(E,2,R,X,Y)
|
||||
#define FP_SQRT_E(R,X) _FP_SQRT(E,2,R,X)
|
||||
|
||||
/*
|
||||
* Square root algorithms:
|
||||
* We have just one right now, maybe Newton approximation
|
||||
* should be added for those machines where division is fast.
|
||||
* We optimize it by doing most of the calculations
|
||||
* in one UWtype registers instead of two, although we don't
|
||||
* have to.
|
||||
*/
|
||||
#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
|
||||
do { \
|
||||
q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
|
||||
_FP_FRAC_SRL_2(X, (_FP_WORKBITS)); \
|
||||
while (q) \
|
||||
{ \
|
||||
T##_f0 = S##_f0 + q; \
|
||||
if (T##_f0 <= X##_f0) \
|
||||
{ \
|
||||
S##_f0 = T##_f0 + q; \
|
||||
X##_f0 -= T##_f0; \
|
||||
R##_f0 += q; \
|
||||
} \
|
||||
_FP_FRAC_SLL_1(X, 1); \
|
||||
q >>= 1; \
|
||||
} \
|
||||
_FP_FRAC_SLL_2(R, (_FP_WORKBITS)); \
|
||||
if (X##_f0) \
|
||||
{ \
|
||||
if (S##_f0 < X##_f0) \
|
||||
R##_f0 |= _FP_WORK_ROUND; \
|
||||
R##_f0 |= _FP_WORK_STICKY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,2,r,X,Y,un)
|
||||
#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,2,r,X,Y)
|
||||
#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,2,r,X,Y)
|
||||
|
||||
#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,2,r,X,rsz,rsg)
|
||||
#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,2,X,r,rs,rt)
|
||||
|
||||
#define _FP_FRAC_HIGH_E(X) (X##_f1)
|
||||
#define _FP_FRAC_HIGH_RAW_E(X) (X##_f0)
|
||||
|
||||
#endif /* not _FP_W_TYPE_SIZE < 64 */
|
||||
53
ExternalApps/RadioSet/main/Source/soft-fp/extendsfdf2.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* Software floating-point emulation.
|
||||
Return a converted to IEEE double
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
#include "double.h"
|
||||
|
||||
DFtype __extendsfdf2(SFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
FP_DECL_D(R);
|
||||
DFtype r;
|
||||
|
||||
FP_INIT_ROUNDMODE;
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
|
||||
FP_EXTEND(D,S,2,1,R,A);
|
||||
#else
|
||||
FP_EXTEND(D,S,1,1,R,A);
|
||||
#endif
|
||||
FP_PACK_RAW_D(r, R);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixdfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
DItype __fixdfdi(DFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_D(A, a);
|
||||
FP_TO_INT_D(r, A, DI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixdfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
SItype __fixdfsi(DFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_D(A, a);
|
||||
FP_TO_INT_D(r, A, SI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixsfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
DItype __fixsfdi(SFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
FP_TO_INT_S(r, A, DI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixsfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
SItype __fixsfsi(SFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
FP_TO_INT_S(r, A, SI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixtfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "quad.h"
|
||||
|
||||
DItype __fixtfdi(TFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_Q(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_Q(A, a);
|
||||
FP_TO_INT_Q(r, A, DI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixtfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit signed integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "quad.h"
|
||||
|
||||
SItype __fixtfsi(TFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_Q(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_Q(A, a);
|
||||
FP_TO_INT_Q(r, A, SI_BITS, 1);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunsdfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
UDItype __fixunsdfdi(DFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_D(A, a);
|
||||
FP_TO_INT_D(r, A, DI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunsdfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
USItype __fixunsdfsi(DFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_D(A, a);
|
||||
FP_TO_INT_D(r, A, SI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunssfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
UDItype __fixunssfdi(SFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
FP_TO_INT_S(r, A, DI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunssfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
USItype __fixunssfsi(SFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_S(A, a);
|
||||
FP_TO_INT_S(r, A, SI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunstfdi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 64bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "quad.h"
|
||||
|
||||
UDItype __fixunstfdi(TFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_Q(A);
|
||||
UDItype r;
|
||||
|
||||
FP_UNPACK_RAW_Q(A, a);
|
||||
FP_TO_INT_Q(r, A, DI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/fixunstfsi.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a to 32bit unsigned integer
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "quad.h"
|
||||
|
||||
USItype __fixunstfsi(TFtype a)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_Q(A);
|
||||
USItype r;
|
||||
|
||||
FP_UNPACK_RAW_Q(A, a);
|
||||
FP_TO_INT_Q(r, A, SI_BITS, 0);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return r;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/floatdidf.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a 64bit signed integer to IEEE double
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
DFtype __floatdidf(DItype i)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
DFtype a;
|
||||
|
||||
FP_FROM_INT_D(A, i, DI_BITS, UDItype);
|
||||
FP_PACK_RAW_D(a, A);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return a;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/floatdisf.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a 64bit signed integer to IEEE single
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
SFtype __floatdisf(DItype i)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
SFtype a;
|
||||
|
||||
FP_FROM_INT_S(A, i, DI_BITS, UDItype);
|
||||
FP_PACK_RAW_S(a, A);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return a;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/floatsidf.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a 32bit signed integer to IEEE double
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "double.h"
|
||||
|
||||
DFtype __floatsidf(SItype i)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_D(A);
|
||||
DFtype a;
|
||||
|
||||
FP_FROM_INT_D(A, i, SI_BITS, USItype);
|
||||
FP_PACK_RAW_D(a, A);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return a;
|
||||
}
|
||||
45
ExternalApps/RadioSet/main/Source/soft-fp/floatsisf.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Software floating-point emulation.
|
||||
Convert a 32bit signed integer to IEEE single
|
||||
Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson (rth@cygnus.com) and
|
||||
Jakub Jelinek (jj@ultra.linux.cz).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Lesser General Public License restrictions do apply in
|
||||
other respects; for example, they cover modification of the file,
|
||||
and distribution when not linked into a combine executable.)
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "soft-fp.h"
|
||||
#include "single.h"
|
||||
|
||||
SFtype __floatsisf(SItype i)
|
||||
{
|
||||
FP_DECL_EX;
|
||||
FP_DECL_S(A);
|
||||
SFtype a;
|
||||
|
||||
FP_FROM_INT_S(A, i, SI_BITS, USItype);
|
||||
FP_PACK_RAW_S(a, A);
|
||||
FP_HANDLE_EXCEPTIONS;
|
||||
|
||||
return a;
|
||||
}
|
||||