/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

#if PL_HAS_SD_CARD
  /* SD card detection: PTE6 with pull-down! */
  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_KEYS
  /* SW3: PTA4 */
  PORT_PDD_SetPinPullSelect(PORTA_BASE_PTR, 4, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTA_BASE_PTR, 4, PORT_PDD_PULL_ENABLE);
  /* SW2: PTC6 */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 6, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_BLUETOOTH
  /* pull up Rx pin (PTC14) for Bluetooth module */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 14, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 14, PORT_PDD_PULL_ENABLE);
#endif
  LED1_On();
  WAIT1_Waitms(50);
  LED1_Off();
  WAIT1_Waitms(50);
  LED2_On();
  WAIT1_Waitms(50);
  LED2_Off();
  WAIT1_Waitms(50);
  LED3_On();
  WAIT1_Waitms(50);
  LED3_Off();
  WAIT1_Waitms(50);
  APP_Start();

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Beispiel #2
0
static bool BL_CheckBootloaderMode(void) {
  /* let's check if the user presses the BTLD switch. Need to configure the pin first */
  /* PTB8 as input */
  /* clock all port pins */
  SIM_SCGC5   |= SIM_SCGC5_PORTA_MASK |
             SIM_SCGC5_PORTB_MASK |
             SIM_SCGC5_PORTC_MASK |
             SIM_SCGC5_PORTD_MASK |
             SIM_SCGC5_PORTE_MASK;
  /* Configure pin as input */
#if 0
  /* GPIOB_PDDR: PDD&=~0x0100 */
  GPIOB_PDDR = (uint32_t)((GPIOB_PDDR & (uint32_t)~0x0100UL) | (uint32_t)0x00UL);

  /* Initialization of Port Control register */
  /* PORTB_PCR8: ISF=0,MUX=1 */
  PORTB_PCR8 = (uint32_t)((PORTB_PCR8 & (uint32_t)~0x01000600UL) | (uint32_t)0x0100UL);
#else
  (void)BitIoLdd3_Init(NULL); /* initialize the port pin PTB8 */
  /* enable internal pull-up on PTB8 */
  PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 8, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 8, PORT_PDD_PULL_ENABLE);
  WAIT1_Waitms(5); /* wait get pull-up a chance to pull-up */
#endif
  if (!BL_SW_GetVal()) { /* button pressed (has pull-up!) */
    WAIT1_Waitms(50); /* wait to debounce */
    if (!BL_SW_GetVal()) { /* still pressed */
      return TRUE; /* go into bootloader mode */
    }
  }
  /* BTLD switch not pressed, and we have a valid user application vector */
  return FALSE; /* do not enter bootloader mode */
}
int main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  
  /* UART Bluetooth Rx on PTC3 and Tx on PTC4 */
  /* pull-up RX/PTC3 for BT_BOARD V1.06 needed, see http://mcuoneclipse.com/2014/03/30/getting-bluetooth-working-with-jy-mcu-bt_board-v1-06/ */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 3, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 3, PORT_PDD_PULL_ENABLE);

  SHELL_Run();

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
  return 0;
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Beispiel #4
0
void APP_Run(void){
	/* SD card detection: PTE6 with pull-down! */
	  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
	  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

	  if (FAT1_Init()!=ERR_OK) { 								/* initialize FAT driver */
	      Err();
	   }
	  if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */
	      Err();
	  }
	  initH3LI(); 												/* init accelerometer */
	  startLog();												/* start the logger */
	  while(counter<((MEASDUR/TICK_MS)-1)){
		  isNewDataAvailable(Z_AXIS_DA, &newDataAvailableFlag); /* check if new data available */
		  if(newDataAvailableFlag == TRUE){
			  logAccData();										/* read sensor and save on SD card */
		  }
		  dataOverrun(Z_AXIS_OR, &dataOverrunFlag);				/* data overrun? */
		  if(dataOverrunFlag == TRUE){
			  count_or++;										/* count overruns */
		  }

	  }
	  stopLog();												/* stop the logger */
	  TI2_Disable();											/* disable the counter */
	  LED_G_Off();
}
Beispiel #5
0
void APP_Run(void) {
#if configUSE_TRACE_HOOKS
  if (RTOSTRC1_uiTraceStart()==0) {
    for(;;){} /* error starting trace recorder. Not setup for enough queues/tasks/etc? */
  }
#endif

#if PL_HAS_SD_CARD
  /* SD card detection: PTB16 with pull-down! */
  PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 16, PORT_PDD_PULL_DOWN);
  PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 16, PORT_PDD_PULL_ENABLE);
#endif
#if PL_HAS_PUSH_BUTTONS
  /* SW2: PTC1 */
  PORT_PDD_SetPinPullSelect(PORTC_BASE_PTR, 1, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTC_BASE_PTR, 1, PORT_PDD_PULL_ENABLE);
  /* SW3: PTB17 */
  PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 17, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 17, PORT_PDD_PULL_ENABLE);
#endif

  LED1_On();
  LED1_Off();
  LED2_On();
  LED2_Off();
  LED3_On();
  LED3_Off();
#if PL_HAS_SHELL
  SHELL_Init();
#endif
#if PL_HAS_ESC
  ESC_Init();
#endif
  if (FRTOS1_xTaskCreate(
      AppTask,  /* pointer to the task */
      "Main", /* task name for kernel awareness debugging */
      configMINIMAL_STACK_SIZE, /* task stack size */
      (void*)NULL, /* optional task startup argument */
      tskIDLE_PRIORITY,  /* initial priority */
      (xTaskHandle*)NULL /* optional task handle to create */
    ) != pdPASS)
  {
    for(;;){} /* error! probably out of memory */
  }
  FRTOS1_vTaskStartScheduler();
  for(;;) {}
}
Beispiel #6
0
void SHELL_Init(void) {
  /* pull-up UART RX line to OpenSDA */
  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 1, PORT_PDD_PULL_UP);
  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 1, PORT_PDD_PULL_ENABLE);

  CLS1_SetStdio(ios[0].stdio); /* using the first one as the default channel */
  if (xTaskCreate(ShellTask, "Shell", 800/sizeof(StackType_t), NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) {
    for(;;){} /* error */
  }
}
Beispiel #7
0
/** Data Collection Session**/
void APP_Run(int sel, int collectCount)
{
	//Local variables.
	int16_t x,y,z;
	uint8_t res;
	char* fileName = malloc(sizeof(char)*256);
	extern int collecting;

	/* SD card detection: PTE6 with pull-down! */
	PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
	PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

	int color;
	char annotation;
	if(sel == 0)
	{
		color = LED_RED;
		annotation = 'w';
	}
	else if(sel == 1)
	{
		color = LED_YELLOW;
		annotation = 'r';
	}
	else if(sel == 2)
	{
		color = LED_GREEN;
		annotation = 'b';
	}
	else if(sel == 3)
	{
		color = LED_CYAN;
		annotation = 'c';
	}
	else if(sel == 4)
	{
		color = LED_BLUE;
		annotation = 'B';
	}
	else if(sel == 5)
	{
		color = LED_MAGENTA;
		annotation = 't';
	}

	sprintf(fileName, "%d-%c.CSV", collectCount, annotation);

	/* create and open file */
	if (FAT1_open(&fp, fileName, FA_OPEN_ALWAYS|FA_WRITE)!=FR_OK) {
	Err(/*CREATE_FILE_ERROR*/);
	}

	/* closing file */
	(void)FAT1_close(&fp);

	int count = 1;
	DataBuffer* myBuffer = getDataBuffer();
	while(isCollectingData()==1)
	{
		if(myBuffer->currentReadBuffer!=-1)
		{
			LogToFile(myBuffer,annotation,fileName);
		}
		WAIT1_Waitms(2);
	}

	me.currentWriteIndex = 0;
}