#define SPI_STATE_IDLE               0x01    //SPI Idle
#define SPI_STATE_START_TX           0x02    //SPI write : prime SPI interface
#define SPI_STATE_TRANS_TX           0x03    //SPI write : transfter samples to SPI
#define SPI_STATE_STOP_TX            0x04    //SPI write : stop/reset SPI interface
#define SPI_STATE_START_RX           0x08    //SPI read  : prime SPI interface
#define SPI_STATE_TRANS_RX           0x09    //SPI read  : transfter to SPI Flash
#define SPI_STATE_STOP_RX            0x0A    //SPI read  : stop/reset interface

#define TASK_EVENT_TX_FLAG           0x1000  //Tx event
#define TASK_EVENT_RX_FLAG           0x2000  //Rx event
#define TASK_EVENT_TX_ERROR_FLAG     0x4000  //Tx error event
#define TASK_EVENT_RX_ERROR_FLAG     0x8000  //Rx error event
#define TASK_EVENT_FLAG              0xF000  //any event


// global variables
uint32_t gSysCtlClock;			//the system clock
OS_TID gTaskSpiFlash2Tx_ID;     //SPI Flash 2 Tx Task ID
OS_TID gTaskSpiFlash2Rx_ID;     //SPI Flash 2 Rx Task ID

void clockInit() {

    // Make sure the main oscillator is enabled because this is required by
    // the PHY.  The system must have a 25MHz crystal attached to the OSC
    // pins.  The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
    // frequency is 10MHz or higher.
	SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);

    // Delay while the main oscillator starts up.
	Delay(5242880);

	//configure the clock
	gSysCtlClock = SysCtlClockFreqSet( 
						SYSCTL_USE_PLL    |
						SYSCTL_OSC_MAIN   |
						SYSCTL_XTAL_25MHZ |
						SYSCTL_CFG_VCO_480,
						120000000);		//desired system frequency
}

__task void taskInit(void) {

	gTaskSpiFlash2Tx_ID= os_tsk_create(taskSpiFlash2Tx,	TASK_SPI_FLASH_TX_PRIORITY);
//	gTaskSpiFlash2Rx_ID= os_tsk_create(taskSpiFlash2Rx,	TASK_SPI_FLASH_RX_PRIORITY);

	//remove the task (not needed any more)
	os_tsk_delete_self();
}
