Example #1
0
void UserRun(void){
#if defined(DEBUG)
	if(GetChannelMode(16)!=IS_UART_TX){
		setMode(16,IS_UART_TX);
		ConfigureUART(115200);
	}
#endif
#if defined(WPIRBE)
	SPISlaveServer();
#endif
#if defined(USE_AS_LIBRARY)
	RunUserCode();
#endif

//	if (Get_UART_Byte_CountPassThrough()>0){
//		PushSerial();
//	}

	if (RunEvery(&block0)>0.0f){
		//println_W("Loop ");p_fl_W(getMs()/1000);
	}

}
Example #2
0
extern "C" void BareMetalSupport_Reset_Handler ( void )
{
    SetupCpuClock();

    // Delay the start-up sequence, so that an external JTAG debugger has a chance
    // to stop the firmware near the beginning.
    //
    // How much busy wait time you need to spend here depends on how fast your JTAG adapter is.
    // With my slow Bus Pirate (at 'normal' speed, instead of 'fast'), and with a non-optimised
    // JtagDue firmware, I need around 34 ms. If you have a fast JTAG probe, you can probably
    // lower this time in order to get faster overall boot times.
    //
    // If you do not need to debug the firmware from the very beginning, or if you do not place
    // breakpoints somewhere during the initialisation code, then you can comment-out this busy wait.
    const unsigned BUSY_WAIT_LOOP_US = 36 * 1000;
    BusyWaitLoop( GetBusyWaitLoopIterationCountFromUs( BUSY_WAIT_LOOP_US ) );


    // Relocate the initialised data from flash to SRAM.

    const uint32_t * relocSrc  = (const uint32_t *)&_etext;
          uint32_t * relocDest = (      uint32_t *)&_srelocate;

    if ( relocSrc != relocDest )
    {
        while ( relocDest < (const uint32_t *) &_erelocate )
        {
            *relocDest++ = *relocSrc++;
        }
    }


    // Clear the zero segment (BSS).

    for ( uint32_t * zeroSegPtr = (uint32_t *)&_szero;  zeroSegPtr < (const uint32_t *) &_ezero;  ++zeroSegPtr )
    {
      *zeroSegPtr = 0;
    }


    // Set the vector table base address.
    const uint32_t * const pVecSrc = (const uint32_t *) & _sfixed;
    SCB->VTOR = ((uint32_t) pVecSrc & SCB_VTOR_TBLOFF_Msk);

    if (((uint32_t) pVecSrc >= IRAM0_ADDR) && ((uint32_t) pVecSrc < NFC_RAM_ADDR))
    {
        SCB->VTOR |= (1UL) << SCB_VTOR_TBLBASE_Pos;
    }


    // The CPU starts at 4 MHz, and that should be the default value of variable SystemCoreClock.
    // We have set the CPU clock above, so update this variable here. Its value is needed
    // in order to calculate the clock delay to get the correct UART speed.

    assert( SystemCoreClock == 4000000 );

    SystemCoreClockUpdate();

    #ifndef NDEBUG
      assert( SystemCoreClock == CPU_CLOCK );
      assert( SystemCoreClock == CHIP_FREQ_CPU_MAX );
    #endif


    // Initialize the C/C++ support by calling all registered constructors.
    __libc_init_array();

    // From this point on, all C/C++ support has been initialised, and the user code can run.

    RunUserCode();

    // If you want to check for memory leaks and so on, you may need to call the destructors here:
    //   __libc_fini_array();

    Panic("RunUserCode() returned unexpectedly.");
}