/* * Copyright (c) 2012, Natie van Rooyen. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. No personal names or organizations' names associated with the * Atomthreads project may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "modules.h" #include #include #include "atomport_private.h" #include "atom.h" #include "atomport.h" /** * \b dbg_format_msg * * Same as printf. * */ void dbg_format_msg (char *format, ...) { va_list args; static char msg[256] ; //CRITICAL_STORE ; va_start (args, format) ; //CRITICAL_START() ; vsniprintf ((char*)msg, 256, (char*)format, args) ; LPC17xx_UART_PutString (msg) ; //CRITICAL_END() ; } /** * \b low_level_init * * Initializes the PIC and start the system timer tick intrerupt. * */ int low_level_init (void) { SystemInit () ; SystemCoreClockUpdate (); //contextInit () ; NVIC_SetPriority (PendSV_IRQn, 0xFF) ; LPC17xx_UART_Init (115200) ; SysTick_Config (1000000) ; return 0 ; } /** * \b __context_preempt_handler * * System timer tic interupt handler. * */ void __context_tick_handler (void) { /* Call the interrupt enter routine */ atomIntEnter(); /* Call the OS system tick handler */ atomTimerTick(); /* Call the interrupt exit routine */ atomIntExit(TRUE); } /** * \b dbg_mem_dump_40 * * Dumps size bytes of memory from data. * */ void dbg_mem_dump_40 (unsigned int* data, int size) { int j ; dbg_format_msg ("Dump %d bytes at %.8X:\r\n",size * 4, (unsigned int)data) ; data = (unsigned int*)((unsigned int)data & ~0x3) ; for (j=0; jSHCSR); dbg_mem_dump_40 (hardfault_args, 0x40) ; while (1); }