Esempio n. 1
0
void systemInit() {
    cpuInit(); // Configure the CPU
    systickInit(CFG_SYSTICK_DELAY_IN_MS); // Start systick timer
    gpioInit(); // Enable GPIO
    pmuInit(); // Configure power management
    step_timer_init();

    // Initialise USB CDC
#ifdef CFG_USBCDC
    lastTick = systickGetTicks(); // Used to control output/printf timing
    CDC_Init(); // Initialise VCOM
    USB_Init(); // USB Initialization
    USB_Connect(TRUE); // USB Connect
    // Wait until USB is configured or timeout occurs
    uint32_t usbTimeout = 0;
    while (usbTimeout < CFG_USBCDC_INITTIMEOUT / 10) {
        if (USB_Configuration)
            break;
        systickDelay(10); // Wait 10ms
        usbTimeout++;
    }
#endif

    // Printf can now be used with UART or USBCDC

}
Esempio n. 2
0
void init ()
{
	cpuInit ();
	systickInit (1);
	gpioInit ();
	pmuInit ();

	CDC_Init ();
	USB_Init ();
	USB_Connect (TRUE);

	gpioSetDir (3, 0, 1);
	gpioSetValue (3, 0, 1);
	while (!USB_Configuration) {
		systickDelay (10);
	}
	gpioSetValue (3, 0, 0); 
}
Esempio n. 3
0
void main(void) {
    // Configure cpu and mandatory peripherals
    cpuInit();                                // Configure the CPU
// we do it later
//    systickInit(CFG_SYSTICK_DELAY_IN_MS);     // Start systick timer
// cpuInit already calls this
//    gpioInit();                               // Enable GPIO 
    pmuInit();                                // Configure power management
    adcInit();                                // Config adc pins to save power

    // initialise basic badge functions
    rbInit();

    initUUID(); // Cache UUID values.
  
    lcdInit(); // display

    lcdFill(0);
    lcdDisplay();
    
    switch(getInputRaw()){
        case BTN_ENTER:
            lcdPrint("ISP active");
            lcdRefresh();
            ReinvokeISP();
            break;
        case BTN_DOWN:
            lcdPrint("MSC active");
            lcdRefresh();
            usbMSCInit();
            while(1);
            break;
    };

    fsInit();

    if( getInputRaw() == BTN_UP ){ // Reset config
            saveConfig();
    }

	wrapper(); // see applications/ subdirectory
}
Esempio n. 4
0
File: main.c Progetto: DanBUK/r0ket
int main(void) {
    // Configure cpu and mandatory peripherals
    cpuInit();                                // Configure the CPU
// we do it later
//    systickInit(CFG_SYSTICK_DELAY_IN_MS);     // Start systick timer
// cpuInit already calls this
//    gpioInit();                               // Enable GPIO 
    pmuInit();                                // Configure power management
    adcInit();                                // Config adc pins to save power

    // initialise basic badge functions
    rbInit();

    fsInit();
  
    lcdInit(); // display

    lcdFill(0);
    lcdDisplay();

	wrapper(); // see module/ subdirectory
}
Esempio n. 5
0
int main(void)
{
  cpuInit();
  systickInit(CFG_SYSTICK_DELAY_IN_MS);

  pmuInit();
  // adcInit();
#ifdef R0KET
  rbInit();
#else
  badge_init();
#endif

  FATFS fs;
  f_mount(0, &fs);

#ifdef USBONLY
  if(badge_input_raw() & BADGE_EVENT_KEY_LEFT) {
    gpioSetValue(HOB_PORT(HOB_LED_LEFT), HOB_PIN(HOB_LED_LEFT) , 1);
  }
  if(badge_input_raw() & BADGE_EVENT_KEY_RIGHT) {
    gpioSetValue(HOB_PORT(HOB_LED_RIGHT), HOB_PIN(HOB_LED_RIGHT) , 1);
  }

  for(;;) usbmode();
#else
  if(badge_input_raw() & BADGE_EVENT_KEY_DOWN) {
    usbmode();
  }

  badge_event_start();
  badge_vanity_show();
  main_menu();
#endif

  return 0;
}
Esempio n. 6
0
File: kerosin.c Progetto: C3MA/r0ket
void main_kerosin(void) {

	uint8_t enterCnt = 0;
	uint8_t buffer[64];
	
//	cpuInit();                                // Configure the CPU
	systickInit(CFG_SYSTICK_DELAY_IN_MS);     // Start systick timer
	gpioInit();                               // Enable GPIO
	pmuInit();                                // Configure power management
	adcInit();                                // Config adc pins to save power
	lcdInit();
		
    DoString(10,5,"USB plug");

	// Initialise USB CDC
#ifdef CFG_USBCDC
    DoString(10, 15, "USBCDC");
    lastTick = systickGetTicks();   // Used to control output/printf timing
    CDC_Init();                     // Initialise VCOM
    USB_Init();                     // USB Initialization
    USB_Connect(TRUE);              // USB Connect
    // Wait until USB is configured or timeout occurs
    uint32_t usbTimeout = 0; 
    while ( usbTimeout < CFG_USBCDC_INITTIMEOUT / 10 )
    {
		if (USB_Configuration) break;
		systickDelay(10);             // Wait 10ms
		usbTimeout++;
    }
#endif
	  // Printf can now be used with UART or USBCDC
	
	puts("Hello World");

	
	DoString(10, 25, "Enter:");
	lcdDisplay();

	
	int readData;
    while (1) {
				
		switch (getInput()) {
			case BTN_ENTER:
				enterCnt++;
				puts("ENTER\t");
				buffer[0] = '0' + enterCnt;
				buffer[1] = 0;
				puts(buffer);
				puts("\r\n");
				DoInt(50, 25, (int) (enterCnt));
				lcdDisplay();				
				break;
			case BTN_LEFT:
				readData = CDC_GetInputBuffer(buffer, sizeof(buffer));
				
				DoString(5, 40, buffer);
				DoString(1, 50, "Received: ");
				DoInt(57, 50, readData);
				lcdDisplay();
				break;
			default:
				break;
		}		
	}
}
Esempio n. 7
0
void systemInit()
{
  cpuInit();
  systickInit((CFG_CPU_CCLK / 1000) * CFG_SYSTICK_DELAY_IN_MS);
  gpioInit();
  pmuInit();
  adcInit();    // Init adc pins to avoid wasting 60uA in deep sleep

  #ifdef CFG_PRINTF_UART
    // Initialise UART with the default baud rate (set in projectconfig.h)
    uartInit(CFG_UART_BAUDRATE);
  #endif

  // Switch to 3.3V if TPS780 (etc.) is being used
  #if defined CFG_VREG_ALT_PRESENT && CFG_VREG_ALT_PRESENT == 1
    gpioSetDir(CFG_VREG_ALT_PORT, CFG_VREG_ALT_PIN, gpioDirection_Output);
    gpioSetValue(CFG_VREG_ALT_PORT, CFG_VREG_ALT_PIN, 0);
    gpioSetPullup(&CFG_VREG_ALT_REG32, gpioPullupMode_Inactive);
  #endif

  // Set LED pin as output and turn LED off
  gpioSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
  gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF);

  // Initialise the ST7565 128x64 pixel display
  #ifdef CFG_ST7565
    st7565Init();
    st7565ClearScreen();    // Clear the screen  
    st7565Backlight(1);     // Enable the backlight
  #endif

  // Initialise the SSD1306 OLED display
  #ifdef CFG_SSD1306
    ssd1306Init(SSD1306_SWITCHCAPVCC);
    ssd1306ClearScreen();   // Clear the screen  
  #endif

  // Initialise EEPROM
  #ifdef CFG_I2CEEPROM
    mcp24aaInit();
  #endif

  // Initialise Chibi
  #ifdef CFG_CHIBI
    // Write addresses to EEPROM for the first time if necessary
    // uint16_t addr_short = 0x1166;
    // uint64_t addr_ieee =  addr_short;
    // mcp24aaWriteBuffer(CFG_CHIBI_EEPROM_SHORTADDR, (uint8_t *)&addr_short, 2);
    // mcp24aaWriteBuffer(CFG_CHIBI_EEPROM_IEEEADDR, (uint8_t *)&addr_ieee, 8);
    chb_init();
  #endif

  // Setup SD Card
  #ifdef CFG_SDCARD
    // Turn off SD card by default (saves power)
    gpioSetDir(CFG_SDCARD_ENPORT, CFG_SDCARD_ENPIN, gpioDirection_Output); /* Set enable pin to output */
    gpioSetValue(CFG_SDCARD_ENPORT, CFG_SDCARD_ENPIN, 0);                  /* Disable card by setting ENPIN low */
    gpioSetPullup(&CFG_SDCARD_ENREG32, gpioPullupMode_Inactive);
  #endif

  #ifdef CFG_LM75B
    // Initialise LM75B
    lm75bInit();
    // Read temp once to make sure we are in sleep mode
    int32_t temp;
    lm75bGetTemperature(&temp);
  #endif

  #ifdef CFG_BAT
    // Turn off battery voltage divider by default
    gpioSetDir(CFG_BAT_ENPORT, CFG_BAT_ENPIN, gpioDirection_Output );   // Set voltage divider enable pin to output
    gpioSetValue(CFG_BAT_ENPORT, CFG_BAT_ENPIN, 0 );                    // Disable the voltage divider by default
    gpioSetPullup(&CFG_BAT_ENREG32, gpioPullupMode_Inactive);
  #endif

  // Start the command line interface (if requested)
  #ifdef CFG_INTERFACE
    printf("%sType '?' for a list of available commands%s", CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE);
    cmdInit();
  #endif
}