Go to the documentation of this file.
25 constexpr
unsigned TargetSystemCoreClock = 48000000;
27 constexpr
unsigned ErrorLedPort = 1;
28 constexpr
unsigned ErrorLedPin = 10;
30 constexpr
unsigned StatusLedPort = 1;
31 constexpr
unsigned StatusLedPin = 11;
39 constexpr PinMuxGroup pinmux[] =
47 void sysctlPowerDown(
unsigned long powerdownmask)
54 void sysctlPowerUp(
unsigned long powerupmask)
66 Chip_Clock_SetWDTClockSource(SYSCTL_WDTCLKSRC_WDTOSC, 1);
75 for (
volatile int i = 0; i < 1000; i++) { }
106 for (
unsigned i = 0; i < (
sizeof(pinmux) /
sizeof(PinMuxGroup)); i++)
108 LPC_IOCON->REG[pinmux[i].pin] = pinmux[i].modefunc;
111 LPC_GPIO[ErrorLedPort].DIR |= 1 << ErrorLedPin;
112 LPC_GPIO[StatusLedPort].DIR |= 1 << StatusLedPin;
139 static const volatile unsigned& DHCSR = *
reinterpret_cast<unsigned*
>(0xE000EDF0U);
145 if ((DHCSR & 1U) != 0)
147 __asm
volatile (
"bkpt #0\n");
157 unsigned aligned_array[5] = {};
158 unsigned iap_command = 58;
159 reinterpret_cast<void(*)(
void*,
void*)
>(0x1FFF1FF1)(&iap_command, aligned_array);
160 std::memcpy(out_uid, &aligned_array[1], 16);
165 LPC_GPIO[StatusLedPort].DATA[1 << StatusLedPin] =
static_cast<unsigned long>(!state) << StatusLedPin;
170 LPC_GPIO[ErrorLedPort].DATA[1 << ErrorLedPin] =
static_cast<unsigned long>(!state) << ErrorLedPin;
@ SYSCTL_BODINTVAL_RESERVED1
void setStatusLed(bool state)
std::uint32_t SystemCoreClock
Initialized to default clock value, will be changed on init.
STATIC INLINE void Chip_Clock_SetupSystemPLL(uint8_t msel, uint8_t psel)
Set System PLL divider values.
@ SYSCTL_MAINCLKSRC_PLLOUT
void syslog(const char *msg)
static constexpr unsigned long PDRUNCFGMASKTMP
const std::uint32_t OscRateIn
External crystal.
STATIC INLINE void Chip_WWDT_Start(LPC_WWDT_T *pWWDT)
Enable WWDT activity.
@ SYSCTL_PLLCLKSRC_MAINOSC
STATIC INLINE bool Chip_Clock_IsSystemPLLLocked(void)
Read System PLL lock status.
static constexpr unsigned UniqueIDSize
STATIC INLINE void Chip_WWDT_SetOption(LPC_WWDT_T *pWWDT, uint32_t options)
Enable watchdog timer options.
STATIC INLINE void Chip_WWDT_SetTimeOut(LPC_WWDT_T *pWWDT, uint32_t timeout)
Set WDT timeout constant value used for feed.
STATIC INLINE void Chip_WWDT_Feed(LPC_WWDT_T *pWWDT)
Feed watchdog timer.
#define SYSCTL_POWERDOWN_SYSPLL_PD
void Chip_Clock_SetSystemPLLSource(CHIP_SYSCTL_PLLCLKSRC_T src)
Set System PLL clock source.
STATIC INLINE void Chip_SYSCTL_EnableBODReset(void)
Enable brown-out detection reset.
STATIC INLINE void Chip_UART_TXEnable(LPC_USART_T *pUART)
Enable transmission on UART TxD pin.
void readUniqueID(std::uint8_t out_uid[UniqueIDSize])
STATIC INLINE void Chip_Clock_SetWDTOSC(CHIP_WDTLFO_OSC_T wdtclk, uint8_t div)
Setup Watchdog oscillator rate and divider.
void Chip_WWDT_Init(LPC_WWDT_T *pWWDT)
Initialize the Watchdog timer.
STATIC INLINE void Chip_Clock_SetSysClockDiv(uint32_t div)
Set system clock divider.
uint32_t Chip_Clock_GetSystemClockRate(void)
Return system clock rate.
uint32_t Chip_UART_SetBaud(LPC_USART_T *pUART, uint32_t baudrate)
Sets best dividers to get a target bit rate (without fractional divider)
void Chip_UART_Init(LPC_USART_T *pUART)
Initializes the pUART peripheral.
void Chip_Clock_SetMainClockSource(CHIP_SYSCTL_MAINCLKSRC_T src)
Set main system clock source.
#define IOCON_MODE_PULLUP
static constexpr unsigned long PDRUNCFGUSEMASK
__attribute__((gnu_inline)) inline void spi_start(uint8_t data)
void setErrorLed(bool state)
#define SYSCTL_POWERDOWN_WDTOSC_PD
#define WWDT_WDMOD_WDRESET
STATIC INLINE void Chip_FMC_SetFLASHAccess(FMC_FLASHTIM_T clks)
Set FLASH access time in clocks.
#define SYSCTL_POWERDOWN_SYSOSC_PD
int Chip_UART_SendBlocking(LPC_USART_T *pUART, const void *data, int numBytes)
Transmit a byte array through the UART peripheral (blocking)
STATIC INLINE void Chip_SYSCTL_SetBODLevels(CHIP_SYSCTL_BODRSTLVL_T rstlvl, CHIP_SYSCTL_BODRINTVAL_T intlvl)
Set brown-out detection interrupt and reset levels.
const std::uint32_t ExtRateIn
Clock rate on the CLKIN pin This value is defined externally to the chip layer and contains the value...