/*********************************************************************//** * @brief c_entry: Main TI program body * @param[in] None * @return int **********************************************************************/ int c_entry(void) { PINSEL_CFG_Type PinCfg; /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); /* * Initialize SSP pin connect * P0.6 - SSEL1 * P0.7 - SCK1 * P0.8 - MISO1 * P0.9 - MOSI1 */ PinCfg.Funcnum = 2; PinCfg.OpenDrain = 0; PinCfg.Pinmode = 0; PinCfg.Portnum = 0; PinCfg.Pinnum = 6; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 7; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 8; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 9; PINSEL_ConfigPin(&PinCfg); /* * Initialize SSP pin connect * P0.15 - SCK * P0.16 - SSEL * P0.17 - MISO * P0.18 - MOSI */ PinCfg.Funcnum = 2; PinCfg.OpenDrain = 0; PinCfg.Pinmode = 0; PinCfg.Portnum = 0; PinCfg.Pinnum = 15; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 17; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 18; PINSEL_ConfigPin(&PinCfg); PinCfg.Pinnum = 16; PINSEL_ConfigPin(&PinCfg); /* Initializing Master SSP device section ------------------------------------------- */ // initialize SSP configuration structure to default SSP_ConfigStructInit(&SSP_ConfigStruct); // Re-configure SSP to TI frame format SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI; // Initialize SSP peripheral with parameter given in structure above SSP_Init(SSPDEV_M, &SSP_ConfigStruct); // Enable SSP peripheral SSP_Cmd(SSPDEV_M, ENABLE); /* Initializing Slave SSP device section ------------------------------------------- */ // initialize SSP configuration structure to default SSP_ConfigStructInit(&SSP_ConfigStruct); /* Re-configure mode for SSP device */ SSP_ConfigStruct.Mode = SSP_SLAVE_MODE; // Re-configure SSP to TI frame format SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI; // Initialize SSP peripheral with parameter given in structure above SSP_Init(SSPDEV_S, &SSP_ConfigStruct); // Enable SSP peripheral SSP_Cmd(SSPDEV_S, ENABLE); /* Interrupt configuration section ------------------------------------------------- */ #if ((USEDSSPDEV_S == 0) || (USEDSSPDEV_M == 0)) /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(SSP0_IRQn, ((0x01<<3)|0x01)); /* Enable SSP0 interrupt */ NVIC_EnableIRQ(SSP0_IRQn); #endif #if ((USEDSSPDEV_S == 1) || (USEDSSPDEV_M == 1)) /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(SSP1_IRQn, ((0x01<<3)|0x01)); /* Enable SSP0 interrupt */ NVIC_EnableIRQ(SSP1_IRQn); #endif /* Initializing Buffer section ------------------------------------------------- */ Buffer_Init(); /* Start Transmit/Receive between Master and Slave ----------------------------- */ complete_S = FALSE; complete_M = FALSE; /* Slave must be ready first */ ssp_SlaveReadWrite(SSPDEV_S, Slave_Rx_Buf, Slave_Tx_Buf, BUFFER_SIZE); /* Then Master can start its transferring */ ssp_MasterReadWrite(SSPDEV_M, Master_Rx_Buf, Master_Tx_Buf, BUFFER_SIZE); /* Wait for complete */ while ((complete_S == FALSE) || (complete_M == FALSE)); /* Verify buffer */ Buffer_Verify(); _DBG_("Verify success!\n\r"); /* Loop forever */ while(1); return 1; }
/*********************************************************************//** * @brief c_entry: Main TI program body * @param[in] None * @return int **********************************************************************/ int c_entry(void) { /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); /* * Initialize SSP pin connect */ #if (SSP0_LOCALTION_NUM == 0) // SSP0 Loc 1 PINSEL_ConfigPin(0, 15, 2); // SCK J5-19 PINSEL_ConfigPin(0, 16, 2); // SSEL J3-24 PINSEL_ConfigPin(0, 17, 2); // MISO J5-20 PINSEL_ConfigPin(0, 18, 2); // MOSI J3-23 #elif (SSP0_LOCALTION_NUM == 1) // SSP0 Loc 2 PINSEL_ConfigPin(1, 20, 5); //SCK J5-32 PINSEL_ConfigPin(1, 28, 5); //SEL J5-36 PINSEL_ConfigPin(1, 23, 5); // MISO J3-35 PINSEL_ConfigPin(1, 24, 5); // MOSI J5-34 #elif (SSP0_LOCALTION_NUM == 2) //SSP0 Loc 3 PINSEL_ConfigPin(2, 22, 2); // SCK J5-47 PINSEL_ConfigPin(2, 23, 2); // SSEL J5-56 PINSEL_ConfigPin(2, 26, 2); // MISO J5-57 PINSEL_ConfigPin(2, 27, 2); // MOSI J5-49 #else while(1); #endif #if (SSP1_LOCALTION_NUM == 0) // Loc 1 PINSEL_ConfigPin(0, 7, 2); // SCK J5.17 PINSEL_SetFilter(0, 7, 0); PINSEL_ConfigPin(0, 6, 2); // SSEL J3.18 PINSEL_ConfigPin(0, 8, 2); // MISO J3.19 PINSEL_SetFilter(0, 8, 0); PINSEL_ConfigPin(0, 9, 2); // MOSI J5.18 PINSEL_SetFilter(0, 9, 0); #elif (SSP1_LOCALTION_NUM == 1) // Loc 2 PINSEL_ConfigPin(1, 19, 5); // SCK J3-33 PINSEL_ConfigPin(1, 26, 5); //SSEL J5-35 PINSEL_ConfigPin(1, 18, 5); //MISO J5-31 PINSEL_ConfigPin(1, 22, 5); //MOSI J5-33 #elif (SSP1_LOCALTION_NUM == 2) // Loc 3 PINSEL_ConfigPin(1, 31, 2); //SCK J3-39 PINSEL_ConfigPin(0, 14, 2); //SSEL J3-21 PINSEL_ConfigPin(0, 12, 2); //MISO J3-22 PINSEL_ConfigPin(0, 13, 2); //MOSI J3-13 #else while(1); #endif /* Initializing Master SSP device section ------------------------------------------- */ // initialize SSP configuration structure to default SSP_ConfigStructInit(&SSP_ConfigStruct); // Re-configure SSP to TI frame format SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI; // Initialize SSP peripheral with parameter given in structure above SSP_Init(SSPDEV_M, &SSP_ConfigStruct); // Enable SSP peripheral SSP_Cmd(SSPDEV_M, ENABLE); /* Initializing Slave SSP device section ------------------------------------------- */ // initialize SSP configuration structure to default SSP_ConfigStructInit(&SSP_ConfigStruct); /* Re-configure mode for SSP device */ SSP_ConfigStruct.Mode = SSP_SLAVE_MODE; // Re-configure SSP to TI frame format SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI; // Initialize SSP peripheral with parameter given in structure above SSP_Init(SSPDEV_S, &SSP_ConfigStruct); // Enable SSP peripheral SSP_Cmd(SSPDEV_S, ENABLE); /* Interrupt configuration section ------------------------------------------------- */ #if ((USEDSSPDEV_S == 0) || (USEDSSPDEV_M == 0)) /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(SSP0_IRQn, ((0x01<<3)|0x01)); /* Enable SSP0 interrupt */ NVIC_EnableIRQ(SSP0_IRQn); #endif #if ((USEDSSPDEV_S == 1) || (USEDSSPDEV_M == 1)) /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(SSP1_IRQn, ((0x01<<3)|0x01)); /* Enable SSP0 interrupt */ NVIC_EnableIRQ(SSP1_IRQn); #endif _DBG_("Press '1' to start transfer..."); while (_DG != '1'); /* Initializing Buffer section ------------------------------------------------- */ Buffer_Init(); /* Start Transmit/Receive between Master and Slave ----------------------------- */ complete_S = FALSE; complete_M = FALSE; /* Slave must be ready first */ ssp_SlaveReadWrite(SSPDEV_S, Slave_Rx_Buf, Slave_Tx_Buf, BUFFER_SIZE); /* Then Master can start its transferring */ ssp_MasterReadWrite(SSPDEV_M, Master_Rx_Buf, Master_Tx_Buf, BUFFER_SIZE); /* Wait for complete */ while ((complete_S == FALSE) || (complete_M == FALSE)); /* Verify buffer */ Buffer_Verify(); _DBG_("Verify success!\n\r"); /* Loop forever */ while(1); }