Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pico SDK to v2.1.0 with RP2350 support #2918

Merged
merged 20 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TODO: flashmem_get_info(), RTC
  • Loading branch information
mikee47 committed Nov 29, 2024
commit 377cdbe9ab5ce585cbc054e125f6043f92790f86
15 changes: 9 additions & 6 deletions Sming/Arch/Rp2040/Components/spi_flash/flashmem.cpp
Original file line number Diff line number Diff line change
@@ -13,9 +13,12 @@
#include <hardware/dma.h>
#include <hardware/regs/addressmap.h>
#include <hardware/structs/xip_ctrl.h>
#include <debug_progmem.h>

#ifdef SOC_RP2040
#include <hardware/structs/ssi.h>
#include <hardware/regs/ssi.h>
#include <debug_progmem.h>
#endif

#define FLASHCMD_READ_SFDP 0x5a
#define FLASHCMD_READ_JEDEC_ID 0x9f
@@ -310,6 +313,7 @@ SPIFlashInfo flashmem_get_info()
SPIFlashInfo info{};
info.size = flashmem_get_size_type();

#ifdef SOC_RP2040
// Flash mode
uint32_t ctrlr0 = ssi_hw->ctrlr0;
auto ssi_frame_format = (ctrlr0 & SSI_CTRLR0_SPI_FRF_BITS) >> SSI_CTRLR0_SPI_FRF_LSB;
@@ -326,6 +330,9 @@ SPIFlashInfo flashmem_get_info()
default:
info.mode = MODE_SLOW_READ;
}
#else
// TODO
#endif

return info;
}
@@ -376,11 +383,7 @@ uint32_t spi_flash_get_id(void)

flash_addr_t flashmem_get_address(const void* memptr)
{
auto addr = uint32_t(memptr);
if(addr < XIP_BASE || addr >= XIP_NOALLOC_BASE) {
return 0;
}
return addr - XIP_BASE;
return isFlashPtr(memptr) ? (uint32_t(memptr) - XIP_BASE) : 0;
}

void flashmem_sfdp_read(uint32_t addr, void* buffer, size_t count)
20 changes: 19 additions & 1 deletion Sming/Arch/Rp2040/Platform/RTC.cpp
Original file line number Diff line number Diff line change
@@ -10,8 +10,12 @@

#include <Platform/RTC.h>
#include <DateTime.h>
#include <hardware/rtc.h>
#include <sys/time.h>
#include <debug_progmem.h>

#ifdef SOC_RP2040
#include <hardware/rtc.h>
#endif

extern "C" int settimeofday(const struct timeval*, const struct timezone*);

@@ -21,9 +25,13 @@ RtcClass RTC;

void system_init_rtc()
{
#ifdef SOC_RP2040
rtc_init();
datetime_t t{.year = 1970, .month = 1, .day = 1};
rtc_set_datetime(&t);
#else
// TODO
#endif
}

RtcClass::RtcClass() = default;
@@ -35,6 +43,7 @@ uint64_t RtcClass::getRtcNanoseconds()

uint32_t RtcClass::getRtcSeconds()
{
#ifdef SOC_RP2040
datetime_t t;
if(!rtc_get_datetime(&t)) {
return 0;
@@ -44,6 +53,10 @@ uint32_t RtcClass::getRtcSeconds()
dt.setTime(t.sec, t.min, t.hour, t.day, t.month - 1, t.year);

return time_t(dt);
#else
debug_w("%s(): TODO", __FUNCTION__);
return 0;
#endif
}

bool RtcClass::setRtcNanoseconds(uint64_t nanoseconds)
@@ -53,6 +66,7 @@ bool RtcClass::setRtcNanoseconds(uint64_t nanoseconds)

bool RtcClass::setRtcSeconds(uint32_t seconds)
{
#ifdef SOC_RP2040
struct timeval tv {
seconds
};
@@ -71,4 +85,8 @@ bool RtcClass::setRtcSeconds(uint32_t seconds)
};

return rtc_set_datetime(&t);
#else
debug_w("%s(): TODO", __FUNCTION__);
return false;
#endif
}