-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from 4ms/lennart_wifi_start
Start wifi interface
- Loading branch information
Showing
30 changed files
with
1,035 additions
and
9 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
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
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
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,11 @@ | ||
LABEL org.opencontainers.image.source=https://github.com/4ms/metamodule | ||
FROM ubuntu:22.04 | ||
|
||
ARG flatbuffer_version=v23.3.3 | ||
|
||
RUN apt update && apt upgrade -y && apt clean | ||
RUN apt update && apt install git ninja-build build-essential bsdmainutils xxd python3 -y && apt clean | ||
RUN apt update && apt install -y cmake && git clone --depth 1 https://github.com/google/flatbuffers -b $flatbuffer_version && cd flatbuffers && cmake -S . -B build -G Ninja && cmake --build build --target install && cd .. && rm -rf flatbuffers && apt remove cmake -y && apt clean | ||
|
||
RUN flatc --version | ||
|
Submodule esp-serial-flasher
added at
0a0073
Submodule flatbuffers
added at
01834d
Submodule mdrivlib
updated
2 files
+22 −0 | drivers/uart.hh | |
+71 −1 | target/stm32mp1/drivers/uart_target.hh |
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
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
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
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,36 @@ | ||
#pragma once | ||
#include "drivers/uart_conf.hh" | ||
#include "drivers/pin.hh" | ||
|
||
|
||
constexpr inline UartConf WifiBootloaderUartConfig{ | ||
.base_addr = USART6_BASE, | ||
.TXPin = {mdrivlib::GPIO::G, mdrivlib::PinNum::_14, mdrivlib::PinAF::AltFunc7}, | ||
.RXPin = {mdrivlib::GPIO::G, mdrivlib::PinNum::_9, mdrivlib::PinAF::AltFunc7}, | ||
.mode = UartConf::Mode::TXRX, | ||
.baud = 115200, // 230400, 921600 | ||
.wordlen = 8, | ||
.parity = UartConf::Parity::None, | ||
.stopbits = UartConf::StopBits::_1, | ||
}; | ||
|
||
constexpr inline UartConf WifiUartConfig{ | ||
.base_addr = UART5_BASE, | ||
.TXPin = {mdrivlib::GPIO::B, mdrivlib::PinNum::_13, mdrivlib::PinAF::AltFunc14}, | ||
.RXPin = {mdrivlib::GPIO::B, mdrivlib::PinNum::_12, mdrivlib::PinAF::AltFunc14}, | ||
.mode = UartConf::Mode::TXRX, | ||
.baud = 115200, // 230400, 921600 | ||
.wordlen = 8, | ||
.parity = UartConf::Parity::None, | ||
.stopbits = UartConf::StopBits::_1, | ||
}; | ||
|
||
constexpr inline mdrivlib::PinDef WifiBootloaderResetConfig{ | ||
mdrivlib::GPIO::G, | ||
mdrivlib::PinNum::_13, | ||
}; | ||
|
||
constexpr inline mdrivlib::PinDef WifiBootloaderBootSelectConfig{ | ||
mdrivlib::GPIO::G, | ||
mdrivlib::PinNum::_8, | ||
}; |
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,73 @@ | ||
#include "BufferedUSART2.h" | ||
|
||
#include "conf/wifi_uart_conf.hh" | ||
#include "drivers/uart.hh" | ||
#include "drivers/uart_conf.hh" | ||
#include "drivers/interrupt.hh" | ||
|
||
#include <stm32mp1xx.h> | ||
#include <stm32mp1xx_ll_usart.h> | ||
#include <stm32mp1xx_ll_usart.h> | ||
|
||
#include <console/pr_dbg.hh> | ||
|
||
static mdrivlib::Uart<WifiUartConfig> commMain; | ||
Queue<uint8_t,256> BufferedUSART2::queue; | ||
|
||
#define USART_PERIPH UART5 | ||
#define USART_IRQ UART5_IRQn | ||
#define USART_IRQ_PRIO 3 | ||
|
||
void BufferedUSART2::init() | ||
{ | ||
initPeripheral(); | ||
} | ||
|
||
bool BufferedUSART2::setBaudrate(uint32_t baudRate) | ||
{ | ||
return commMain.set_baudrate(baudRate); | ||
} | ||
|
||
void BufferedUSART2::initPeripheral() | ||
{ | ||
commMain.init(); | ||
|
||
mdrivlib::Interrupt::register_and_start_isr(USART_IRQ, USART_IRQ_PRIO, 0, []() | ||
{ | ||
if (LL_USART_IsActiveFlag_RXNE_RXFNE(USART_PERIPH)) | ||
{ | ||
do | ||
{ | ||
auto val = USART_PERIPH->RDR; | ||
|
||
auto result = queue.Push(val); | ||
if (not result) | ||
{ | ||
pr_err("RX Overrun\n"); | ||
} | ||
} | ||
while (LL_USART_IsActiveFlag_RXNE(USART_PERIPH)); | ||
} | ||
else | ||
{ | ||
printf_("No flag\n"); | ||
} | ||
}); | ||
|
||
// read RX from hardware to clear RXNE flag | ||
(void)USART_PERIPH->RDR; | ||
|
||
LL_USART_EnableIT_RXNE_RXFNE(USART_PERIPH); | ||
} | ||
|
||
void BufferedUSART2::transmit(uint8_t val) | ||
{ | ||
commMain.transmit(val); | ||
} | ||
|
||
std::optional<uint8_t> BufferedUSART2::receive() | ||
{ | ||
return queue.PopOptional(); | ||
} | ||
|
||
|
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,24 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <spsc/queue.hpp> | ||
using namespace lockfree::spsc; | ||
|
||
|
||
|
||
class BufferedUSART2 | ||
{ | ||
public: | ||
static void init(); | ||
|
||
static bool setBaudrate(uint32_t); | ||
|
||
static void transmit(uint8_t); | ||
static std::optional<uint8_t> receive(); | ||
|
||
private: | ||
static void initPeripheral(); | ||
|
||
private: | ||
static Queue<uint8_t,256> queue; | ||
}; |
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,18 @@ | ||
/* Author: Lennart@binarylabs.dev */ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace Framing | ||
{ | ||
|
||
struct Configuration_t | ||
{ | ||
uint8_t start; | ||
uint8_t end; | ||
uint8_t escape; | ||
}; | ||
|
||
|
||
} |
Oops, something went wrong.