Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx 2023-05-19 08:16:05 +12:00 committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
599 changed files with 70746 additions and 66896 deletions

View file

@ -29,40 +29,38 @@ namespace gpdma {
namespace {
struct ChannelHandlers {
TCHandler tc;
ErrHandler err;
TCHandler tc;
ErrHandler err;
constexpr ChannelHandlers(
) : tc(nullptr),
err(nullptr)
{
}
constexpr ChannelHandlers()
: tc(nullptr),
err(nullptr) {
}
};
}
} // namespace
static std::array<ChannelHandlers, channels.size()> handlers_table { {} };
static std::array<ChannelHandlers, channels.size()> handlers_table{{}};
namespace channel {
void Channel::set_handlers(const TCHandler tc_handler, const ErrHandler err_handler) const {
handlers_table[number].tc = tc_handler;
handlers_table[number].err = err_handler;
handlers_table[number].tc = tc_handler;
handlers_table[number].err = err_handler;
}
void Channel::configure(
const LLI& first_lli,
const uint32_t config
) const {
disable();
clear_interrupts();
const LLI& first_lli,
const uint32_t config) const {
disable();
clear_interrupts();
LPC_GPDMA_Channel_Type* const channel = &LPC_GPDMA->CH[number];
channel->SRCADDR = first_lli.srcaddr;
channel->DESTADDR = first_lli.destaddr;
channel->LLI = first_lli.lli;
channel->CONTROL = first_lli.control;
channel->CONFIG = config;
LPC_GPDMA_Channel_Type* const channel = &LPC_GPDMA->CH[number];
channel->SRCADDR = first_lli.srcaddr;
channel->DESTADDR = first_lli.destaddr;
channel->LLI = first_lli.lli;
channel->CONTROL = first_lli.control;
channel->CONFIG = config;
}
} /* namespace channel */
@ -70,42 +68,42 @@ void Channel::configure(
extern "C" {
CH_IRQ_HANDLER(DMA_IRQHandler) {
CH_IRQ_PROLOGUE();
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
chSysLockFromIsr();
const auto tc_stat = LPC_GPDMA->INTTCSTAT;
/* TODO: Service the higher channel numbers first, they're higher priority
* right?!?
*/
for(size_t i=0; i<handlers_table.size(); i++) {
if( (tc_stat >> i) & 1 ) {
if( handlers_table[i].tc ) {
handlers_table[i].tc();
}
}
}
LPC_GPDMA->INTTCCLR = tc_stat;
const auto tc_stat = LPC_GPDMA->INTTCSTAT;
/* TODO: Service the higher channel numbers first, they're higher priority
* right?!?
*/
for (size_t i = 0; i < handlers_table.size(); i++) {
if ((tc_stat >> i) & 1) {
if (handlers_table[i].tc) {
handlers_table[i].tc();
}
}
}
LPC_GPDMA->INTTCCLR = tc_stat;
/* Test for *any* error first, before looping, since errors should be
* exceptional and we should spend as little time on them in the common
* case.
*/
const auto err_stat = LPC_GPDMA->INTERRSTAT;
if( err_stat ) {
for(size_t i=0; i<handlers_table.size(); i++) {
if( (err_stat >> i) & 1 ) {
if( handlers_table[i].err ) {
handlers_table[i].err();
}
}
}
LPC_GPDMA->INTERRCLR = err_stat;
}
/* Test for *any* error first, before looping, since errors should be
* exceptional and we should spend as little time on them in the common
* case.
*/
const auto err_stat = LPC_GPDMA->INTERRSTAT;
if (err_stat) {
for (size_t i = 0; i < handlers_table.size(); i++) {
if ((err_stat >> i) & 1) {
if (handlers_table[i].err) {
handlers_table[i].err();
}
}
}
LPC_GPDMA->INTERRCLR = err_stat;
}
chSysUnlockFromIsr();
chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
CH_IRQ_EPILOGUE();
}
}