mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jun 17 11:00:07 2014 +0100
Revision:
232:1e593fe58241
Synchronized with git revision 990a82a00808c8148a6e542650e5f5fe9339ea9f

Full URL: https://github.com/mbedmicro/mbed/commit/990a82a00808c8148a6e542650e5f5fe9339ea9f/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 232:1e593fe58241 1 extern "C" {
mbed_official 232:1e593fe58241 2
mbed_official 232:1e593fe58241 3 #include "LPC11U6x.h"
mbed_official 232:1e593fe58241 4 #define WEAK __attribute__ ((weak))
mbed_official 232:1e593fe58241 5 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
mbed_official 232:1e593fe58241 6 #define AFTER_VECTORS __attribute__ ((section(".after_vectors")))void ResetISR(void);
mbed_official 232:1e593fe58241 7
mbed_official 232:1e593fe58241 8 // Patch the AEABI integer divide functions to use MCU's romdivide library
mbed_official 232:1e593fe58241 9 #ifdef __USE_ROMDIVIDE
mbed_official 232:1e593fe58241 10 // Location in memory that holds the address of the ROM Driver table
mbed_official 232:1e593fe58241 11 #define PTR_ROM_DRIVER_TABLE ((unsigned int *)(0x1FFF1FF8))
mbed_official 232:1e593fe58241 12 // Variables to store addresses of idiv and udiv functions within MCU ROM
mbed_official 232:1e593fe58241 13 unsigned int *pDivRom_idiv;
mbed_official 232:1e593fe58241 14 unsigned int *pDivRom_uidiv;
mbed_official 232:1e593fe58241 15 #endif
mbed_official 232:1e593fe58241 16
mbed_official 232:1e593fe58241 17
mbed_official 232:1e593fe58241 18 extern unsigned int __data_section_table;
mbed_official 232:1e593fe58241 19 extern unsigned int __data_section_table_end;
mbed_official 232:1e593fe58241 20 extern unsigned int __bss_section_table;
mbed_official 232:1e593fe58241 21 extern unsigned int __bss_section_table_end;
mbed_official 232:1e593fe58241 22
mbed_official 232:1e593fe58241 23
mbed_official 232:1e593fe58241 24 extern void __libc_init_array(void);
mbed_official 232:1e593fe58241 25 extern int main(void);
mbed_official 232:1e593fe58241 26 extern void _vStackTop(void);
mbed_official 232:1e593fe58241 27 extern void (* const g_pfnVectors[])(void);
mbed_official 232:1e593fe58241 28
mbed_official 232:1e593fe58241 29 void ResetISR(void);
mbed_official 232:1e593fe58241 30 WEAK void NMI_Handler(void);
mbed_official 232:1e593fe58241 31 WEAK void HardFault_Handler(void);
mbed_official 232:1e593fe58241 32 WEAK void SVC_Handler(void);
mbed_official 232:1e593fe58241 33 WEAK void PendSV_Handler(void);
mbed_official 232:1e593fe58241 34 WEAK void SysTick_Handler(void);
mbed_official 232:1e593fe58241 35 WEAK void IntDefaultHandler(void);
mbed_official 232:1e593fe58241 36
mbed_official 232:1e593fe58241 37 void PIN_INT0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 38 void PIN_INT1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 39 void PIN_INT2_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 40 void PIN_INT3_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 41 void PIN_INT4_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 42 void PIN_INT5_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 43 void PIN_INT6_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 44 void PIN_INT7_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 45 void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 46 void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 47 void I2C1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 48 void USART1_4_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 49 void USART2_3_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 50 void SCT0_1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 51 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 52 void I2C0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 53 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 54 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 55 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 56 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 57 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 58 void USART0_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 59 void USB_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 60 void USB_FIQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 61 void ADCA_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 62 void RTC_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 63 void BOD_WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 64 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 65 void DMA_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 66 void ADCB_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 67 void USBWakeup_IRQHandler (void) ALIAS(IntDefaultHandler);
mbed_official 232:1e593fe58241 68
mbed_official 232:1e593fe58241 69 __attribute__ ((section(".isr_vector")))
mbed_official 232:1e593fe58241 70 void (* const g_pfnVectors[])(void) = {
mbed_official 232:1e593fe58241 71 // Core Level - CM0
mbed_official 232:1e593fe58241 72 &_vStackTop, // The initial stack pointer
mbed_official 232:1e593fe58241 73 ResetISR, // The reset handler
mbed_official 232:1e593fe58241 74 NMI_Handler, // The NMI handler
mbed_official 232:1e593fe58241 75 HardFault_Handler, // The hard fault handler
mbed_official 232:1e593fe58241 76 0, // Reserved
mbed_official 232:1e593fe58241 77 0, // Reserved
mbed_official 232:1e593fe58241 78 0, // Reserved
mbed_official 232:1e593fe58241 79 0, // Reserved
mbed_official 232:1e593fe58241 80 0, // Reserved
mbed_official 232:1e593fe58241 81 0, // Reserved
mbed_official 232:1e593fe58241 82 0, // Reserved
mbed_official 232:1e593fe58241 83 SVC_Handler, // SVCall handler
mbed_official 232:1e593fe58241 84 0, // Reserved
mbed_official 232:1e593fe58241 85 0, // Reserved
mbed_official 232:1e593fe58241 86 PendSV_Handler, // The PendSV handler
mbed_official 232:1e593fe58241 87 SysTick_Handler, // The SysTick handler
mbed_official 232:1e593fe58241 88
mbed_official 232:1e593fe58241 89 // Chip Level - LPC11U68
mbed_official 232:1e593fe58241 90 PIN_INT0_IRQHandler, // 0 - GPIO pin interrupt 0
mbed_official 232:1e593fe58241 91 PIN_INT1_IRQHandler, // 1 - GPIO pin interrupt 1
mbed_official 232:1e593fe58241 92 PIN_INT2_IRQHandler, // 2 - GPIO pin interrupt 2
mbed_official 232:1e593fe58241 93 PIN_INT3_IRQHandler, // 3 - GPIO pin interrupt 3
mbed_official 232:1e593fe58241 94 PIN_INT4_IRQHandler, // 4 - GPIO pin interrupt 4
mbed_official 232:1e593fe58241 95 PIN_INT5_IRQHandler, // 5 - GPIO pin interrupt 5
mbed_official 232:1e593fe58241 96 PIN_INT6_IRQHandler, // 6 - GPIO pin interrupt 6
mbed_official 232:1e593fe58241 97 PIN_INT7_IRQHandler, // 7 - GPIO pin interrupt 7
mbed_official 232:1e593fe58241 98 GINT0_IRQHandler, // 8 - GPIO GROUP0 interrupt
mbed_official 232:1e593fe58241 99 GINT1_IRQHandler, // 9 - GPIO GROUP1 interrupt
mbed_official 232:1e593fe58241 100 I2C1_IRQHandler, // 10 - I2C1
mbed_official 232:1e593fe58241 101 USART1_4_IRQHandler, // 11 - combined USART1 & 4 interrupt
mbed_official 232:1e593fe58241 102 USART2_3_IRQHandler, // 12 - combined USART2 & 3 interrupt
mbed_official 232:1e593fe58241 103 SCT0_1_IRQHandler, // 13 - combined SCT0 and 1 interrupt
mbed_official 232:1e593fe58241 104 SSP1_IRQHandler, // 14 - SPI/SSP1 Interrupt
mbed_official 232:1e593fe58241 105 I2C0_IRQHandler, // 15 - I2C0
mbed_official 232:1e593fe58241 106 TIMER16_0_IRQHandler, // 16 - CT16B0 (16-bit Timer 0)
mbed_official 232:1e593fe58241 107 TIMER16_1_IRQHandler, // 17 - CT16B1 (16-bit Timer 1)
mbed_official 232:1e593fe58241 108 TIMER32_0_IRQHandler, // 18 - CT32B0 (32-bit Timer 0)
mbed_official 232:1e593fe58241 109 TIMER32_1_IRQHandler, // 19 - CT32B1 (32-bit Timer 1)
mbed_official 232:1e593fe58241 110 SSP0_IRQHandler, // 20 - SPI/SSP0 Interrupt
mbed_official 232:1e593fe58241 111 USART0_IRQHandler, // 21 - USART0
mbed_official 232:1e593fe58241 112 USB_IRQHandler, // 22 - USB IRQ
mbed_official 232:1e593fe58241 113 USB_FIQHandler, // 23 - USB FIQ
mbed_official 232:1e593fe58241 114 ADCA_IRQHandler, // 24 - ADC A(A/D Converter)
mbed_official 232:1e593fe58241 115 RTC_IRQHandler, // 25 - Real Time CLock interrpt
mbed_official 232:1e593fe58241 116 BOD_WDT_IRQHandler, // 25 - Combined Brownout/Watchdog interrupt
mbed_official 232:1e593fe58241 117 FMC_IRQHandler, // 27 - IP2111 Flash Memory Controller
mbed_official 232:1e593fe58241 118 DMA_IRQHandler, // 28 - DMA interrupt
mbed_official 232:1e593fe58241 119 ADCB_IRQHandler, // 24 - ADC B (A/D Converter)
mbed_official 232:1e593fe58241 120 USBWakeup_IRQHandler, // 30 - USB wake-up interrupt
mbed_official 232:1e593fe58241 121 0, // 31 - Reserved
mbed_official 232:1e593fe58241 122 };
mbed_official 232:1e593fe58241 123 /* End Vector */
mbed_official 232:1e593fe58241 124
mbed_official 232:1e593fe58241 125 AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
mbed_official 232:1e593fe58241 126 unsigned int *pulDest = (unsigned int*) start;
mbed_official 232:1e593fe58241 127 unsigned int *pulSrc = (unsigned int*) romstart;
mbed_official 232:1e593fe58241 128 unsigned int loop;
mbed_official 232:1e593fe58241 129 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++;
mbed_official 232:1e593fe58241 130 }
mbed_official 232:1e593fe58241 131
mbed_official 232:1e593fe58241 132 AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) {
mbed_official 232:1e593fe58241 133 unsigned int *pulDest = (unsigned int*) start;
mbed_official 232:1e593fe58241 134 unsigned int loop;
mbed_official 232:1e593fe58241 135 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0;
mbed_official 232:1e593fe58241 136 }
mbed_official 232:1e593fe58241 137
mbed_official 232:1e593fe58241 138
mbed_official 232:1e593fe58241 139 /* Reset entry point*/
mbed_official 232:1e593fe58241 140 extern "C" void software_init_hook(void) __attribute__((weak));
mbed_official 232:1e593fe58241 141
mbed_official 232:1e593fe58241 142 AFTER_VECTORS void ResetISR(void) {
mbed_official 232:1e593fe58241 143 unsigned int LoadAddr, ExeAddr, SectionLen;
mbed_official 232:1e593fe58241 144 unsigned int *SectionTableAddr;
mbed_official 232:1e593fe58241 145
mbed_official 232:1e593fe58241 146 SectionTableAddr = &__data_section_table;
mbed_official 232:1e593fe58241 147
mbed_official 232:1e593fe58241 148 while (SectionTableAddr < &__data_section_table_end) {
mbed_official 232:1e593fe58241 149 LoadAddr = *SectionTableAddr++;
mbed_official 232:1e593fe58241 150 ExeAddr = *SectionTableAddr++;
mbed_official 232:1e593fe58241 151 SectionLen = *SectionTableAddr++;
mbed_official 232:1e593fe58241 152 data_init(LoadAddr, ExeAddr, SectionLen);
mbed_official 232:1e593fe58241 153 }
mbed_official 232:1e593fe58241 154 while (SectionTableAddr < &__bss_section_table_end) {
mbed_official 232:1e593fe58241 155 ExeAddr = *SectionTableAddr++;
mbed_official 232:1e593fe58241 156 SectionLen = *SectionTableAddr++;
mbed_official 232:1e593fe58241 157 bss_init(ExeAddr, SectionLen);
mbed_official 232:1e593fe58241 158 }
mbed_official 232:1e593fe58241 159
mbed_official 232:1e593fe58241 160 // Patch the AEABI integer divide functions to use MCU's romdivide library
mbed_official 232:1e593fe58241 161 #ifdef __USE_ROMDIVIDE
mbed_official 232:1e593fe58241 162 // Get address of Integer division routines function table in ROM
mbed_official 232:1e593fe58241 163 unsigned int *div_ptr = (unsigned int *)((unsigned int *)*(PTR_ROM_DRIVER_TABLE))[4];
mbed_official 232:1e593fe58241 164 // Get addresses of integer divide routines in ROM
mbed_official 232:1e593fe58241 165 // These address are then used by the code in aeabi_romdiv_patch.s
mbed_official 232:1e593fe58241 166 pDivRom_idiv = (unsigned int *)div_ptr[0];
mbed_official 232:1e593fe58241 167 pDivRom_uidiv = (unsigned int *)div_ptr[1];
mbed_official 232:1e593fe58241 168 #endif
mbed_official 232:1e593fe58241 169
mbed_official 232:1e593fe58241 170
mbed_official 232:1e593fe58241 171 SystemInit();
mbed_official 232:1e593fe58241 172 if (software_init_hook)
mbed_official 232:1e593fe58241 173 software_init_hook();
mbed_official 232:1e593fe58241 174 else {
mbed_official 232:1e593fe58241 175 __libc_init_array();
mbed_official 232:1e593fe58241 176 main();
mbed_official 232:1e593fe58241 177 }
mbed_official 232:1e593fe58241 178 while (1) {;}
mbed_official 232:1e593fe58241 179 }
mbed_official 232:1e593fe58241 180
mbed_official 232:1e593fe58241 181 AFTER_VECTORS void NMI_Handler (void) {}
mbed_official 232:1e593fe58241 182 AFTER_VECTORS void HardFault_Handler (void) {}
mbed_official 232:1e593fe58241 183 AFTER_VECTORS void MemManage_Handler (void) {}
mbed_official 232:1e593fe58241 184 AFTER_VECTORS void BusFault_Handler (void) {}
mbed_official 232:1e593fe58241 185 AFTER_VECTORS void UsageFault_Handler(void) {}
mbed_official 232:1e593fe58241 186 AFTER_VECTORS void SVC_Handler (void) {}
mbed_official 232:1e593fe58241 187 AFTER_VECTORS void DebugMon_Handler (void) {}
mbed_official 232:1e593fe58241 188 AFTER_VECTORS void PendSV_Handler (void) {}
mbed_official 232:1e593fe58241 189 AFTER_VECTORS void SysTick_Handler (void) {}
mbed_official 232:1e593fe58241 190 AFTER_VECTORS void IntDefaultHandler (void) {}
mbed_official 232:1e593fe58241 191
mbed_official 232:1e593fe58241 192 int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) {return 0;}
mbed_official 232:1e593fe58241 193 }
mbed_official 232:1e593fe58241 194
mbed_official 232:1e593fe58241 195 #include <stdlib.h>
mbed_official 232:1e593fe58241 196
mbed_official 232:1e593fe58241 197 void *operator new(size_t size) {return malloc(size);}
mbed_official 232:1e593fe58241 198 void *operator new[](size_t size){return malloc(size);}
mbed_official 232:1e593fe58241 199
mbed_official 232:1e593fe58241 200 void operator delete(void *p) {free(p);}
mbed_official 232:1e593fe58241 201 void operator delete[](void *p) {free(p);}