Esempio n. 1
0
void cleanFlash(void) {
    ledsSet(0xffff);
    extFlashBulkErase();
    extFlashAddr = 0;
    // start with zeros
    extFlashWrite(extFlashAddr, (uint8_t *) &extFlashAddr, 4);
    extFlashAddr = 4;
    ledsSet(0x0);
}
Esempio n. 2
0
Amb8420InitCode_e amb8420Reset(void)
{
    bool ok;
    Handle_t h;
    Amb8420InitCode_e result = AMB8420_INIT_HARD_FAIL;

    RPRINTF("amb8420Reset\n");

    if (serial[AMB8420_UART_ID].function != SERIAL_FUNCTION_RADIO) {
        amb8420InitSerial();
    }

    AMB8420ModeContext_t ctx;
    // the chip cannot be configured while in sleep mode
    AMB8420_ENTER_ACTIVE_MODE(ctx);

    RPRINTF("active mode ok\n");

    pinClear(AMB8420_RESET_PORT, AMB8420_RESET_PIN);
    ledsSet(0xff);
    mdelay(200);
    ledsSet(0);
    pinSet(AMB8420_RESET_PORT, AMB8420_RESET_PIN);

    mdelay(500);

    // wait for initialization to complete
    AMB8420_WAIT_FOR_RTS_READY(ok);
    if (!ok) goto end;
    RPRINTF("  init completed\n");
  
    ATOMIC_START(h);
    udelay(100);

    // Switch to command mode (generate falling front)
    pinClear(AMB8420_CONFIG_PORT, AMB8420_CONFIG_PIN);
    mdelay(1);
    pinSet(AMB8420_CONFIG_PORT, AMB8420_CONFIG_PIN);

    ATOMIC_END(h);

    // Wait for device to become ready
    AMB8420_WAIT_FOR_RTS_READY(ok);

    if (ok) {
        RPRINTF("  device ready\n");
        result = AMB8420_INIT_SUCCESS;
    } else {
        RPRINTF("  device NOT ready\n");
    }

  end:
    // restore sleep mode
    AMB8420_RESTORE_MODE(ctx);
    return result;
}
Esempio n. 3
0
int main(void) {
  u08 c;
  char buffer[7];
  int  num=1;
  bool isFlowControlOn = true;
  bool isHexModeOn = false;

  ledsSet(1);
  ledsInit();
  
  ledsSet(2);
  uartInit( UART_BAUD_SELECT( 9600, F_CPU ) );
  
  ledsSet(3);
  uartFlowControlOn( true );
  
  ledsSet(4);
  uartPutString("String stored in SRAM\n");
  
  ledsSet(5);    
  uartPutString("String stored in FLASH\n");
  
  ledsSet(6);        
  itoa( num, buffer, 10);       // convert interger into string (decimal format)         
  uartPutString(buffer);        // and transmit string to UART
  uartPutString( "\n" );
  
  ledsSet(7);    
  //while ( !uartIsCharAvailable() ) {
    //do nothing
  //}
  //c = uartBlockingGetChar();
  uartPutString( "You pressed: " );
  //uartPutChar( c );
  uartPutString( "\n" );
  
  for(;;) {
    ledsSet(11);    
    c = uartBlockingGetChar();
    //_delay_ms( 100 );
    ledsSet(12);    
    
    if ( c == 'V' ) {
      uartPutString( "testSerial: " );
      uartPutString( __DATE__ );
      uartPutString( " " );
      uartPutString( __TIME__ );
      uartPutString( "\n" );
    } else if ( c == 'B' ) {
      MCUCR = _BV(IVCE);
      MCUCR = _BV(IVSEL);               //move interruptvectors to the boot sector sector
      asm volatile("jmp 0x3800");
    } else if ( c == 'F' ) {
Esempio n. 4
0
//-------------------------------------------
//      Entry point for the application
//-------------------------------------------
void appMain(void)
{
    while (1)
    {
        static uint_t i;
        // test 1: counter 0-7
        for (i = 0; i < 8; ++i) {
            ledsSet(i);
            msleep(PAUSE);
        }

        // test 2: all off, then red on/off, then green on/off, finally blue on/off
        ledsSet(0);
        msleep(PAUSE);
        redLedOn();
        msleep(PAUSE);
        redLedOff();
        msleep(PAUSE);

        greenLedOn();
        msleep(PAUSE);
        greenLedOff();
        msleep(PAUSE);

        blueLedOn();
        msleep(PAUSE);
        blueLedOff();
        msleep(PAUSE);

        // test 3: all on, then blue off, green off, red off
        ledsSet(7);
        msleep(PAUSE);
        blueLedOff();
        msleep(PAUSE);
        greenLedOff();
        msleep(PAUSE);
        redLedOff();
        msleep(PAUSE);

        // test 4: repeat last two tests with toggle
        redLedToggle();
        msleep(PAUSE);
        redLedToggle();
        msleep(PAUSE);

        greenLedToggle();
        msleep(PAUSE);
        greenLedToggle();
        msleep(PAUSE);

        blueLedToggle();
        msleep(PAUSE);
        blueLedToggle();
        msleep(PAUSE);

        ledsSet(7);
        msleep(PAUSE);
        blueLedToggle();
        msleep(PAUSE);
        greenLedToggle();
        msleep(PAUSE);
        redLedToggle();
        msleep(PAUSE);

        // test 5: check that isOn functions work
        ledsSet(0);
        ASSERT(!redLedGet());
        ASSERT(!greenLedGet());
        ASSERT(!blueLedGet());
        ledsSet(7);
        ASSERT(redLedGet());
        ASSERT(greenLedGet());
        ASSERT(blueLedGet());
    } // EOF while (1)
}