Skip to content

Commit

Permalink
Apply coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Mar 17, 2024
1 parent c385992 commit ee236ae
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern void ets_wdt_enable(void);
extern void ets_wdt_disable(void);
extern void wdt_feed(void);


/** @brief Disable interrupts
* @retval Current interrupt level
* @note Hardware timer is unaffected if operating in non-maskable mode
Expand Down
12 changes: 6 additions & 6 deletions Sming/Arch/Rp2040/Components/rp2040/src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#include <pico/util/queue.h>
#include <sming_attr.h>

namespace {

namespace
{
class TaskQueue
{
public:
static void init()
{
spinlock = spin_lock_claim_unused(true);
spinlock = spin_lock_claim_unused(true);
}

TaskQueue(os_task_t callback, uint8_t length): callback(callback)
TaskQueue(os_task_t callback, uint8_t length) : callback(callback)
{
queue_init_with_spinlock(&queue, sizeof(os_event_t), length, spinlock);
}
Expand All @@ -26,7 +26,7 @@ class TaskQueue

bool __forceinline post(os_signal_t sig, os_param_t par)
{
os_event_t event {sig, par};
os_event_t event{sig, par};
return queue_try_add(&queue, &event);
}

Expand Down Expand Up @@ -60,7 +60,7 @@ const uint8_t SYSTEM_TASK_QUEUE_LENGTH = 8;

TaskQueue* task_queues[SYSTEM_TASK_PRIO + 1];

};
}; // namespace

bool system_os_task(os_task_t callback, os_task_priority_t prio, os_event_t* events, uint8_t qlen)
{
Expand Down
40 changes: 21 additions & 19 deletions Sming/Arch/Rp2040/Components/rp2040/src/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ extern "C" {
IMPORT_FSTR_ARRAY_LOCAL(cyw43_firmware, uint8_t, CYW43_FIRMWARE)
#endif

namespace {

namespace
{
#define BUFFER_SIZE 16384
#define DICT_SIZE 32767

class Decompressor {
class Decompressor
{
public:
explicit Decompressor(const FSTR::ObjectBase& data) : stream(new FlashMemoryStream(data))
{
Expand All @@ -39,24 +40,24 @@ class Decompressor {
uzlib_init();
uzlib_uncompress_init(&state, dict, DICT_SIZE);
state.source_read_cb = read_source;
int res = uzlib_gzip_parse_header(&state);
if (res != TINF_OK) {
int res = uzlib_gzip_parse_header(&state);
if(res != TINF_OK) {
debug_e("[CYW] bad GZIP header %d", res);
return false;
}
return true;
return true;
}

bool read(void* dest, size_t length)
{
state.dest = static_cast<uint8_t*>(dest);
state.dest_limit = state.dest + length;
int res = uzlib_uncompress_chksum(&state);
state.dest = static_cast<uint8_t*>(dest);
state.dest_limit = state.dest + length;
int res = uzlib_uncompress_chksum(&state);
if(res != TINF_OK) {
debug_e("[CYW] Decompress error %d", res);
return false;
}
return true;
return true;
}

private:
Expand All @@ -75,15 +76,16 @@ class Decompressor {
return *self->state.source++;
}

struct uzlib_uncomp state{};
struct uzlib_uncomp state {
};
uint8_t src_buffer[BUFFER_SIZE]{};
uint8_t dict[DICT_SIZE];
uint8_t dict[DICT_SIZE];
std::unique_ptr<IDataSourceStream> stream;
};

std::unique_ptr<Decompressor> decompressor;

}
} // namespace

int cyw43_storage_init()
{
Expand All @@ -98,12 +100,12 @@ int cyw43_storage_init()
}
#endif

if (!decompressor || !decompressor->init()) {
if(!decompressor || !decompressor->init()) {
decompressor.reset();
return -1;
}
return -1;
}

return 0;
return 0;
}

uint32_t cyw43_storage_read(void* dest, uint32_t length)
Expand All @@ -115,9 +117,9 @@ uint32_t cyw43_storage_read(void* dest, uint32_t length)
if(!decompressor->read(dest, length)) {
decompressor.reset();
return 0;
}
}

return length;
return length;
}

void cyw43_storage_cleanup()
Expand Down

0 comments on commit ee236ae

Please sign in to comment.