Exemplo n.º 1
0
int main() {
    /* Initialise the hardware */
    bspInit();
    robotInit();

    /* Initialise the OS */
    OSInit();


    /* Create emergency stop task */
    OSTaskCreate(appTaskEmergencyStop,
                 (void *)0,
                 (OS_STK *)&appTaskEmergencyStopStk[APP_TASK_EMERGENCY_STOP_STK_SIZE - 1],
                 APP_TASK_EMERGENCY_STOP_PRIO);

    /* Create buttons task, used when testing to get robot positions */
    OSTaskCreate(appTaskButtons,
                 (void *)0,
                 (OS_STK *)&appTaskButtonsStk[APP_TASK_BUTTONS_STK_SIZE - 1],
                 APP_TASK_BUTTONS_PRIO);

    /* Create move block task for the moving of the block from conveyor to pad 2 */
    OSTaskCreate(appTaskMoveBlock,
                 (void *)0,
                 (OS_STK *)&appTaskMoveBlockStk[APP_TASK_MOVE_BLOCK_STK_SIZE - 1],
                 APP_TASK_MOVE_BLOCK_PRIO);

    /* Start the OS */
    OSStart();

    /* Should never arrive here */
    return 0;
}
/*******************************************************************************
*   @fn         initMCU
*
*   @brief      Initialize MCU and board peripherals
*
*   @param      none
*
*   @return     none
*/
static void initMCU(void) {

    // Init clocks and I/O
    bspInit(BSP_SYS_CLK_8MHZ);

    // Init LEDs
    bspLedInit();

    // Init buttons
    bspKeyInit(BSP_KEY_MODE_POLL);

    // Initialize SPI interface to LCD (shared with SPI flash)
    bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD);

    // Init LCD
    lcdInit();

    // Instantiate transceiver RF SPI interface to SCLK ~ 4 MHz
    // Input parameter is clockDivider
    // SCLK frequency = SMCLK/clockDivider
    trxRfSpiInterfaceInit(2);

    // Enable global interrupt
    _BIS_SR(GIE);
}
Exemplo n.º 3
0
int main() {

  /* Initialise the board support package */
  bspInit();

  /* Initialise the OS */
  OSInit();                                                   

  /* Create the tasks */
  OSTaskCreate(appTaskLink,                               
               (void *)0,
               (OS_STK *)&appTaskLinkStk[APP_TASK_LINK_STK_SIZE - 1],
               APP_TASK_LINK_PRIO);

  OSTaskCreate(appTaskConnect,                               
               (void *)0,
               (OS_STK *)&appTaskConnectStk[APP_TASK_CONNECT_STK_SIZE - 1],
               APP_TASK_CONNECT_PRIO);

  OSTaskCreate(appTaskCANWrite,                               
               (void *)0,
               (OS_STK *)&appTaskCANWriteStk[APP_TASK_CAN_WRITE_STK_SIZE - 1],
               APP_TASK_CAN_WRITE_PRIO);

  OSTaskCreate(appTaskCANRead,                               
               (void *)0,
               (OS_STK *)&appTaskCANReadStk[APP_TASK_CAN_READ_STK_SIZE - 1],
               APP_TASK_CAN_READ_PRIO);
  
  /* Start the OS */
  OSStart();                                                  
  
  /* Should never arrive here */ 
  return 0;      
}
Exemplo n.º 4
0
int main() {
  /* Initialise the hardware */
  bspInit();
  conveyorInit();
 
  /* Initialise the OS */
  OSInit();                                                   

  /* Create Tasks */
  OSTaskCreate(appTaskEmergencyStop,                               
               (void *)0,
               (OS_STK *)&appTaskEmergencyStopStk[APP_TASK_EMERGENCY_STOP_STK_SIZE - 1],
               APP_TASK_EMERGENCY_STOP_PRIO);
  OSTaskCreate(appTaskMonitorSens1,                               
               (void *)0,
               (OS_STK *)&appTaskMonitorSens1Stk[APP_TASK_MONITOR_SENS1_STK_SIZE - 1],
               APP_TASK_MONITOR_SENS1_PRIO);
  OSTaskCreate(appTaskMonitorSens2,                               
               (void *)0,
               (OS_STK *)&appTaskMonitorSens2Stk[APP_TASK_MONITOR_SENS2_STK_SIZE - 1],
               APP_TASK_MONITOR_SENS2_PRIO);
 
   
  /* Start the OS */
  OSStart();                                                  
  
  /* Should never arrive here */ 
  return 0;      
}
Exemplo n.º 5
0
int main() {
  uint8_t error;

  /* Initialise the hardware */ 
  bspInit();
  interfaceInit(NO_DEVICE);

  /* Initialise the OS */
  OSInit();                                                   

  /* Create Tasks */
  OSTaskCreate(appTaskCanReceive,                               
               (void *)0,
               (OS_STK *)&appTaskCanReceiveStk[APP_TASK_CAN_RECEIVE_STK_SIZE - 1],
               APP_TASK_CAN_RECEIVE_PRIO);
 
  OSTaskCreate(appTaskCanMonitor,                               
               (void *)0,
               (OS_STK *)&appTaskCanMonitorStk[APP_TASK_CAN_MONITOR_STK_SIZE - 1],
               APP_TASK_CAN_MONITOR_PRIO);

  /* Create Semaphores and Mutexes */
  can1RxSem = OSSemCreate(0);
  displayMutex = OSMutexCreate(DISPLAY_MUTEX_PRIO, &error);
      
  /* Start the OS */
  OSStart();                                                  
  
  /* Should never arrive here */ 
  return 0;      
}
Exemplo n.º 6
0
static void
board_init(void)
{
    /* Initialise the board */
    bspInit(BSP_SYS_CLK_SPD);

    IntMasterEnable();
}
Exemplo n.º 7
0
int main( void )
{
	uint8_t tmpBuff[100];
	
	uint32_t time = 0;
	
	
	// Init clock and IO
	bspInit();
	
	// Init UART 
	bspUartInit();
	
//	RF_Config();
	
	Relay_Init();
	Relay_Off(ROne);
	
	LED_API.Init();
	
	// Enable global interrupt
	__bis_SR_register(GIE);
	
	bspUartDataPut("Tra Quang Kieu", 14);
	
	time = TWO_HOUR;
	
	for(;;)
	{
		LED_API.Toggle(LED1);
//		Relay_Toggle(ROne);
//		Relay_Toggle(RTwo);
		if (time == 0)
		{
			time = EIGHT_HOUR;
			Relay_Toggle(ROne);
		}
		else
		{
			time--;
		}
		if (bspUartDataGet(tmpBuff, 10) > 0)
		{
			if (memcmp(tmpBuff, "on\n", 3) == 0)
			{
				Relay_On(ROne);
			}
			else if (memcmp(tmpBuff, "off\n", 4) == 0)
			{
				Relay_Off(ROne);
			}
		}
//		bspUartDataPut("Tra Quang Kieu", 14);
		
		__delay_cycles(16000000);
	}
}
Exemplo n.º 8
0
int main() {
  /* Initialise the hardware */
  bspInit();
  robotInit();

  /* Initialise the OS */
  OSInit();                                                   

  /* Create Tasks */
  OSTaskCreate(appTaskButtons,                               
               (void *)0,
               (OS_STK *)&appTaskButtonsStk[APP_TASK_BUTTONS_STK_SIZE - 1],
               APP_TASK_BUTTONS_PRIO);

  /* Start the OS */
  OSStart();                                                  
  
  /* Should never arrive here */ 
  return 0;      
}
Exemplo n.º 9
0
/**************************************************************************//**
* @brief    Main function of example.
******************************************************************************/
void main(void)
{
    uint8_t ui8KeyBm = 0;
    uint_fast16_t ui16Cnt = 0;
    uint8_t ui8Byte = APP_TX_BYTE;

    //
    // Initialize clocks and board I/O
    //
    bspInit(BSP_SYS_CLK_SPD);

    //
    // Set LED1 to indicate life
    //
    bspLedSet(BSP_LED_1);

    //
    // Initialize key driver
    //
    bspKeyInit(BSP_KEY_MODE_ISR);
    bspKeyIntEnable(BSP_KEY_SELECT|BSP_KEY_UP);

    //
    // Initialize UART to USB MCU
    //
    bspUartBufInit(pui8TxBuf, sizeof(pui8TxBuf), pui8RxBuf, sizeof(pui8RxBuf));

    //
    // Application must register the UART interrupt handler
    //
    UARTIntRegister(BSP_UART_BASE, &appUartIsr);

    //
    // Open UART connection
    //
    if(bspUartOpen(eBaudRate115200) != BSP_UART_SUCCESS)
    {
        //
        // Failed to initialize UART handler
        //
        bspAssert();
    }

    //
    // Initialize SPI interface to LCD, configure LCD, and display information.
    //
    bspSpiInit(BSP_SPI_CLK_SPD);
    lcdInit();
    lcdBufferPrintStringAligned(0, "UART example", eLcdAlignCenter, eLcdPage0);
    lcdBufferInvertPage(0, 0,127, eLcdPage0);
    lcdBufferPrintString(0, "Baud rate   :", 6, eLcdPage2);
    lcdBufferPrintIntAligned(0, bspUartBaudRateGet(), eLcdAlignRight, eLcdPage2);
    lcdBufferPrintString(0, "Format      :", 6, eLcdPage3);
    lcdBufferPrintStringAligned(0, "8-N-1", eLcdAlignRight, eLcdPage3);
    lcdBufferPrintString(0, "Flow control:", 6, eLcdPage4);
    lcdBufferPrintStringAligned(0, "No", eLcdAlignRight, eLcdPage4);
    lcdBufferPrintStringAligned(0, "Transmit: UP key", eLcdAlignRight, eLcdPage6);
    lcdBufferPrintStringAligned(0, "SELECT to toggle mode", eLcdAlignCenter, eLcdPage7);
    lcdBufferInvertPage(0, 0,127, eLcdPage7);
    lcdSendBuffer(0);

    //
    // Enable global interrupts
    //
    IntMasterEnable();

    while(1)
    {
        ui8KeyBm = bspKeyPushed(BSP_KEY_ALL);

        if(BSP_KEY_SELECT & ui8KeyBm)
        {
            //
            // Change mode
            //
            bRepeaterMode ^= 1;
            bspLedToggle(BSP_LED_3);

            //
            // Update LCD for the new mode
            //
            lcdBufferClearPart(0, 0,127, eLcdPage6, eLcdPage6);
            if(bRepeaterMode)
            {
                lcdBufferPrintStringAligned(0, "Repeater mode",
                                            eLcdAlignCenter, eLcdPage6);
            }
            else
            {
                lcdBufferPrintStringAligned(0, "Transmit: UP key",
                                            eLcdAlignCenter, eLcdPage6);
            }
            lcdSendBufferPart(0, 0,127, eLcdPage6, eLcdPage6);
        }

        //
        // Read data from UART RX buffer to application buffer
        //
        ui16Cnt = bspUartDataGet(pui8AppBuf, bspUartRxCharsAvail());

        if(bRepeaterMode)
        {
            //
            // Repeater mode
            //

            if(ui16Cnt)
            {
                //
                // Send data from application buffer to UART TX buffer
                //
                bspUartDataPut(pui8AppBuf, ui16Cnt);
            }
        }
        else
        {
            //
            // Transmit mode
            //

            if(BSP_KEY_UP & ui8KeyBm)
            {
                //
                // Transmit a single character
                //
                bspUartDataPut(&ui8Byte, 1);
            }
        }
    }
}
Exemplo n.º 10
0
/******************************************************************************
 * @fn          main
 *
 * @brief       Main handles all applications attached to the menu system
 *
 * input parameters
 *
 * output parameters
 *
 *@return
 */
void main( void )
{
   
  // Init clocks and I/O 
  bspInit(BSP_SYS_CLK_16MHZ);
  
  // Init leds 
  bspLedInit(); 

  // Init Buttons
  bspKeyInit(BSP_KEY_MODE_POLL);
  
  // Initialize SPI interface to LCD (shared with SPI flash)
  bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD);  

  /* Init Buttons */
  bspKeyInit(BSP_KEY_MODE_ISR);
  bspKeyIntEnable(BSP_KEY_ALL);
  /* Init LCD and issue a welcome */
  lcdInit();
  lcdClear();
  // Instantiate tranceiver RF spi interface to SCLK ~ 4 MHz */
  //input clockDivider - SMCLK/clockDivider gives SCLK frequency
  trxRfSpiInterfaceInit(0x10);
  
  /* Welcome Screen Part */
  lcdSendBuffer(trxebWelcomeScreen);
  lcdBufferPrintString(lcdDefaultBuffer,"TEXAS",60,eLcdPage6);
  lcdBufferPrintString(lcdDefaultBuffer,"INSTRUMENTS",60,eLcdPage7);
  lcdSendBufferPart(lcdDefaultBuffer, 60,127,eLcdPage6, eLcdPage7);
  /* MCU will stay in sleep until button is pressed */
  __low_power_mode_3();
  bspKeyPushed(BSP_KEY_ALL);
  //Clear screen
  lcdBufferClear(0);

  /* Menu Driver */
  menu_t *pCurrentMenu = &mainMenu;
  uint8 menuButtonsPressed;
  menuDisplay(pCurrentMenu);
  __low_power_mode_3();
  while(1)
  {
    menuButtonsPressed = bspKeyPushed(BSP_KEY_ALL);
    switch(menuButtonsPressed)
    {
      case BSP_KEY_LEFT:
        pCurrentMenu = menuBack(pCurrentMenu);
        break;
      case BSP_KEY_RIGHT:
        pCurrentMenu = menuEnter(pCurrentMenu);
        break;
      case BSP_KEY_DOWN:
        menuDown(pCurrentMenu);
        break;
      case BSP_KEY_UP:
        menuUp(pCurrentMenu);
        break;
      default:
        break;
    }
    menuDisplay(pCurrentMenu);
    /* Enter low power mode while menu driver waits on user input */
    __low_power_mode_3();
  }
}
Exemplo n.º 11
0
//
// Application entry point
//
int main(void)
{
    KEYBOARD_IN_REPORT keybReport;
    uint8_t keybReportSendReq = false;
    uint8_t currKey = 0x00;

    //
    // Initialize board and system clock
    //
    bspInit(SYS_CTRL_32MHZ);

    //
    // Enable the USB interface
    //
    usbHidInit();

    //
    // Initialize GPIO pins for keyboard LEDs (LED 1 on PC0 is used by USB to
    // control D+ pull-up)
    //
    GPIOPinTypeGPIOOutput(BSP_LED_BASE, BSP_LED_2 | BSP_LED_3 | BSP_LED_4);

    //
    // Configure interrupt with wakeup for all buttons
    //
    IntRegister(INT_GPIOA, selKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_SEL_BASE, BSP_KEY_SELECT, GPIO_POW_RISING_EDGE);
    IntRegister(INT_GPIOC, dirKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_DIR_BASE, BSP_KEY_DIR_ALL, GPIO_POW_RISING_EDGE);

    //
    // Initialize button polling for keyboard HID reports
    //
    memset(&keybReport, 0x00, sizeof(KEYBOARD_IN_REPORT));

    //
    // Main loop
    //
    while (1)
    {

        //
        // Process USB events
        //
        usbHidProcessEvents();

        //
        // Generate keyboard input
        //
        if (!keybReportSendReq)
        {
            switch (bspKeyPushed(BSP_KEY_ALL))
            {
            case BSP_KEY_LEFT:
                currKey = 0x50;
                break;
            case BSP_KEY_RIGHT:
                currKey = 0x4F;
                break;
            case BSP_KEY_UP:
                currKey = 0x52;
                break;
            case BSP_KEY_DOWN:
                currKey = 0x51;
                break;
            case BSP_KEY_SELECT:
                currKey = 0x28;
                break;
            default:
                currKey = 0x00;
                break;
            }
            if (currKey != keybReport.pKeyCodes[0])
            {
                keybReport.pKeyCodes[0] = currKey;
                hidUpdateKeyboardInReport(&keybReport);
                keybReportSendReq = true;
            }
        }
        if (keybReportSendReq)
        {
            if (hidSendKeyboardInReport())
            {
                keybReportSendReq = false;
            }
        }
    }

}
Exemplo n.º 12
0
/***************************************************************************//**
 *   @brief      Initialize MCU and BOARD Peripherals
 *
 *	 @note 		This function initializes the following
 *	 @note 		\li \b MCU \b Clock
 *	 @note 		\li \b BSP \b keys
 *	 @note 		\li \b BSP \b LEDs
 *	 @note 		\li \b LCD display (only for TRXEB)
 *	 @note 		\li \b RF_SPI Interface
 *	 @note 		\li \b UART interface
 *	 @note 		\li \b PA_LNA controls
 *	 @note 		\li \b TIMER Bit Rate for the symbols
 *	 @note 		\li \b INTERRUPT enable service
 *******************************************************************************/
static void
initMCU(void)
{
	// Initialize clocks and I/O
	//bspInit(BSP_SYS_CLK_20MHZ);
	bspInit(BSP_SYS_CLK_24MHZ);

	// Initialize buttons
	bspKeyInit(BSP_KEY_MODE_POLL);

	// Initialize leds
	bspLedInit();

#ifdef __MSP430F5438A__
	// Initialize SPI interface to LCD (shared with SPI flash)
	bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD);

	// Initialize LCD
	lcdInit();
#endif
	// Instantiate transceiver RF SPI interface to SCLK ~ 8 MHz */
	/* Input parameter is clockDivider
	 * SCLK frequency = SMCLK/clockDivider
	 */
	//trxRfSpiInterfaceInit(2);
	trxRfSpiInterfaceInit(3);

#ifdef AT_CMD
	// Initialize the UART interface
	halUartInit();

	// Toggle UART Echo. Disabled by default. Might cause unwanted behaviour if enabled.
	// Note: Try enabling local echo on the host console instead!
	//uartDrvToggleEcho();
#endif

#ifdef __MSP430F5529__
	// remove the reset from the rf device
	RF_RESET_N_PORT_SEL &= ~RF_RESET_N_PIN;
	RF_RESET_N_PORT_DIR |= RF_RESET_N_PIN;
	RF_RESET_N_PORT_OUT |= RF_RESET_N_PIN;
#endif
#ifdef CC1190_PA_LNA
	// initialize the IO
	RF_PA_EN_PxDIR |= RF_PA_EN_PIN;
	RF_LNA_EN_PxDIR |= RF_LNA_EN_PIN;

	// configure idle
	RF_PA_EN_PxOUT &= ~RF_PA_EN_PIN;
	RF_LNA_EN_PxOUT &= ~RF_LNA_EN_PIN;
#endif

	// Init Bitrate Timer
	/* - FCC bit rate  = 1.66ms ( 600bps )
	 * - ETSI bit rate = 10 ms  ( 100bps )
	 */
	TIMER_bitrate_init();

	// Enable global interrupt
	_BIS_SR(GIE);
}