KEEP(*(.data_at_1c)) |
__attribute__ ((section(".data_at_1c"))) uint32_t checksum_placeholder = 0; |
//***************************************************************************** // NanoBlinkySequel.c // A newly created adaptation of // //***************************************************************************** // The tiniest C blink program for LPC17xx - 28 bytes + vec. checksum = 32 B // Copyright (c) 2011 gbm //***************************************************************************** // // By larryvc // Now the tiniest C blink program for LPC17xx - 28 bytes total // Real men don't need the checksum vector allocated if the code is short enough // //***************************************************************************** #include "LPC17xx.h" #define LED_PORT LPC_GPIO0 #define LED_MASK (1 << 22) // set shift (left or right) so that LED state is controlled by bit 19..21 // of free-running counter variable #define SHIFT(a) (a << 5) int main(void); //***************************************************************************** // External declaration for the pointer to the stack top from the Linker Script //***************************************************************************** extern void _vStackTop(void); //***************************************************************************** // The vector table. // This relies on the linker script to place at correct location in memory. //***************************************************************************** extern void (* const g_pfnVectors[])(void); __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { &_vStackTop,// The initial stack pointer (const void *)main, // Replaced ResetISR() with main() - allows debugging and disassembly listing to be displayed }; __attribute__ ((section(".code_at_8"))) int main(void) { uint32_t i;// real men don't need to initialize variables LED_PORT->FIODIR = LED_MASK; while (1) { LED_PORT->FIOPIN = SHIFT(i++); } } |
unsigned int *p = (unsigned int *)FIO0PIN; if(*p & LEDPIN) { p += 2; } else { p++; } *p = LEDPIN; |
/* =============================================================================== Name : main.c Author : Version : Copyright : Copyright (C) Description : main definition =============================================================================== */ #ifdef __USE_CMSIS #include "LPC11xx.h" #endif #include <cr_section_macros.h> #include <NXP/crp.h> // Variable to store CRP value in. Will be placed automatically // by the linker when "Enable Code Read Protect" selected. // See crp.h header for more information //__CRP const unsigned int CRP_WORD = CRP_NO_CRP ; #define STCTRL 0xE000E010 #define RELOAD 0xE000E014 #define FIO0DIR 0x50008000 #define FIO0PIN 0x50003FFC #define LEDPIN (1<<7) volatile unsigned int msTicks; int main(void) { unsigned int *p = (unsigned int *)STCTRL; //STCTRL = 7 enable timer and interrupt *p = 7; p = (unsigned int *)RELOAD; //RELOAD = (FIRC / 100) - 1 = 40,000 - 1 = 39,999 = 0x9C3F // 10 mSec *p = 0x9C3F; p = (unsigned int *)FIO0DIR; *p = LEDPIN; msTicks = 0; // enable all interrupts __asm volatile ("cpsie i"); // Enter an infinite loop while(1) { } return 0 ; } void SysTick_Handler(void) { msTicks++; if(msTicks >= (50)) { msTicks = 0; unsigned int *p = (unsigned int *)FIO0PIN; if(*p & LEDPIN) { p += 2; } else { p++; } *p = LEDPIN; } } |
/* =============================================================================== Name : main.c Author : Version : Copyright : Copyright (C) Description : main definition =============================================================================== */ #ifdef __USE_CMSIS #include "LPC17xx.h" #endif #include <cr_section_macros.h> #include <NXP/crp.h> // Variable to store CRP value in. Will be placed automatically // by the linker when "Enable Code Read Protect" selected. // See crp.h header for more information __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; #define STCTRL 0xE000E010 #define RELOAD 0xE000E014 #define FIO0DIR 0x2009C000 #define FIO0PIN 0x2009C014 #define LEDPIN (1<<22) volatile unsigned int msTicks; int main(void) { unsigned int *p = (unsigned int *)STCTRL; //STCTRL = 7 enable timer and interrupt *p = 7; p = (unsigned int *)RELOAD; //RELOAD = (FIRC / 100) - 1 = 40,000 - 1 = 39,999 = 0x9C3F // 10 mSec *p = 0x9C3F; p = (unsigned int *)FIO0DIR; *p = LEDPIN; msTicks = 0; // enable all interrupts __asm volatile ("cpsie i"); // Enter an infinite loop while(1) { } return 0 ; } void SysTick_Handler(void) { msTicks++; if(msTicks >= (50)) { msTicks = 0; unsigned int *p = (unsigned int *)FIO0PIN; if(*p & LEDPIN) { p += 2; } else { p++; } *p = LEDPIN; } } |