-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ (emc): Modernize certification emc test
bt_lcd_qspi_rfid_touch_wifi only
- Loading branch information
1 parent
f1c517b
commit 260c3aa
Showing
4 changed files
with
98 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/functional/cert/emc_bt_lcd_qspi_rfid_touch_wifi/CoreFlashUtils.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Leka - LekaOS | ||
// Copyright 2021 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <lstd_array> | ||
|
||
#include "rtos/ThisThread.h" | ||
|
||
#include "CoreFlashUtils.h" | ||
|
||
using namespace leka; | ||
using namespace std::chrono; | ||
|
||
CoreQSPI coreqspi {}; | ||
CoreFlashManagerIS25LP016D coremanageris25lp(coreqspi); | ||
CoreFlashIS25LP016D coreis25lp(coreqspi, coremanageris25lp); | ||
|
||
uint32_t address = 0x00; | ||
|
||
const size_t bytes_to_read = 0x20; | ||
std::array<uint8_t, bytes_to_read> buffer {}; | ||
|
||
auto data_to_write = lstd::to_array<uint8_t>({1, 2, 3, 4, 5, 6, 7, 8, 9}); | ||
|
||
void flash_loop() | ||
{ | ||
coreis25lp.reset(); | ||
|
||
rtos::ThisThread::sleep_for(2s); | ||
|
||
auto data_transmission_format = leka::interface::QSPI::DataTransmissionFormat {}; | ||
coreqspi.setDataTransmissionFormat(data_transmission_format); | ||
coreqspi.setFrequency(flash::is25lp016d::max_clock_frequency_in_hz); | ||
|
||
coreis25lp.erase(); | ||
|
||
while (true) { | ||
rtos::ThisThread::sleep_for(200ms); | ||
|
||
auto bytes_written = coreis25lp.write(address, data_to_write, std::size(data_to_write)); | ||
coreis25lp.read(address, buffer, bytes_written); | ||
|
||
if (auto new_address = address + bytes_to_read; new_address > coreis25lp.getSize()) { | ||
address = 0x00; | ||
} else { | ||
address = new_address; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/functional/cert/emc_bt_lcd_qspi_rfid_touch_wifi/CoreFlashUtils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Leka - LekaOS | ||
// Copyright 2021 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "CoreFlashIS25LP016D.h" | ||
#include "CoreFlashManagerIS25LP016D.h" | ||
#include "CoreQSPI.h" | ||
|
||
extern leka::CoreQSPI coreqspi; | ||
extern leka::CoreFlashManagerIS25LP016D coremanageris25lp; | ||
extern leka::CoreFlashIS25LP016D coreis25lp; | ||
|
||
__attribute__((noreturn)) void flash_loop(); |
63 changes: 33 additions & 30 deletions
63
tests/functional/cert/emc_bt_lcd_qspi_rfid_touch_wifi/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,75 @@ | ||
// Leka - LekaOS | ||
// Copyright 2020 APF France handicap | ||
// Copyright 2021 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "mbed.h" | ||
#include "drivers/BufferedSerial.h" | ||
#include "drivers/Ticker.h" | ||
#include "drivers/Watchdog.h" | ||
#include "rtos/ThisThread.h" | ||
#include "rtos/Thread.h" | ||
|
||
#include "CoreFlashUtils.h" | ||
#include "HelloWorld.h" | ||
#include "LekaBluetooth.h" | ||
#include "LekaFirmware.h" | ||
#include "LekaRFID.h" | ||
#include "LekaScreen.h" | ||
#include "LekaTouch.h" | ||
#include "LekaWifi.h" | ||
#include "LogKit.h" | ||
|
||
using namespace leka; | ||
using namespace std::chrono; | ||
|
||
HelloWorld hello; | ||
Bluetooth leka_bluetooth; | ||
Firmware leka_firmware; | ||
RFID leka_rfid; | ||
Screen leka_screen; | ||
Touch leka_touch; | ||
Wifi leka_wifi; | ||
|
||
static BufferedSerial serial(USBTX, USBRX, 9600); | ||
static mbed::BufferedSerial serial(USBTX, USBRX, 115200); | ||
|
||
constexpr uint8_t buff_size = 128; | ||
char buff[buff_size] {}; | ||
std::array<char, buff_size> buff {}; | ||
|
||
Thread bluetooth_thread; | ||
Thread firmware_thread; | ||
Thread rfid_thread; | ||
Thread screen_thread; | ||
Thread touch_thread; | ||
Thread wifi_thread; | ||
rtos::Thread bluetooth_thread; | ||
rtos::Thread flash_thread; | ||
rtos::Thread rfid_thread; | ||
rtos::Thread screen_thread; | ||
rtos::Thread touch_thread; | ||
rtos::Thread wifi_thread; | ||
|
||
Ticker kicker; | ||
mbed::Ticker kicker; | ||
const uint32_t TIMEOUT_MS = 5000; | ||
|
||
void watchdogKick() | ||
{ | ||
Watchdog::get_instance().kick(); | ||
mbed::Watchdog::get_instance().kick(); | ||
} | ||
|
||
int main(void) | ||
auto main() -> int | ||
{ | ||
auto start = Kernel::Clock::now(); | ||
log_info("Hello, Investigation Day!\n\n"); | ||
|
||
printf("\nHello, Investigation Day!\n\n"); | ||
auto start = rtos::Kernel::Clock::now(); | ||
|
||
rtos::ThisThread::sleep_for(2s); | ||
|
||
Watchdog &watchdog = Watchdog::get_instance(); | ||
auto &watchdog = mbed::Watchdog::get_instance(); | ||
watchdog.start(TIMEOUT_MS); | ||
kicker.attach_us(watchdogKick, 1000); | ||
|
||
bluetooth_thread.start(callback(&leka_bluetooth, &Bluetooth::start)); | ||
// firmware_thread.start(callback(&leka_firmware, &Firmware::start)); | ||
rfid_thread.start(callback(&leka_rfid, &RFID::start)); | ||
screen_thread.start(callback(&leka_screen, &Screen::start)); | ||
touch_thread.start(callback(&leka_touch, &Touch::start)); | ||
wifi_thread.start(callback(&leka_wifi, &Wifi::start)); | ||
bluetooth_thread.start(mbed::callback(&leka_bluetooth, &Bluetooth::start)); | ||
flash_thread.start(flash_loop); | ||
rfid_thread.start(mbed::callback(&leka_rfid, &RFID::start)); | ||
screen_thread.start(mbed::callback(&leka_screen, &Screen::start)); | ||
touch_thread.start(mbed::callback(&leka_touch, &Touch::start)); | ||
wifi_thread.start(mbed::callback(&leka_wifi, &Wifi::start)); | ||
hello.start(); | ||
|
||
while (true) { | ||
auto t = Kernel::Clock::now() - start; | ||
int length = sprintf(buff, "A message from your board %s --> \"%s\" at %i s\n", MBED_CONF_APP_TARGET_NAME, | ||
hello.world, int(t.count() / 1000)); | ||
serial.write(buff, length); | ||
auto t = rtos::Kernel::Clock::now() - start; | ||
log_info("A message from your board %s --> \"%s\" at %i s\n", MBED_CONF_APP_TARGET_NAME, hello.world, | ||
int(t.count() / 1000)); | ||
|
||
rtos::ThisThread::sleep_for(1s); | ||
} | ||
} |