Ejemplo n.º 1
0
/******************************************************************************
 ** \brief Change CAN FD transceiver mode
 **
 ** Changes the CAN FD transceiver mode for specified channel.
 ** In the target environment, TJA1145 is mounted. This transceiver transits to 
 ** the 'Standby' mode after starting by turning the power on. So its mode should 
 ** be changed to the 'Normal' mode to communicate via CAN.
 **
 ** \param [in] c                     CAN FD channel number (0-).
 ** \param [in] m                     CAN FD transceiver mode
 **                                     1(001B) : Sleep mode
 **                                     4(100B) : Standby mode
 **                                     7(111B) : Normal mode
 ******************************************************************************/
static void CanfdDriverSetMode(uint8_t c, uint8_t m)
{
    uint16_t u16Data;
	// Check parameter.
	if (c == 0)
	{
        // CS = L
        Gpio1pin_Put(GPIO1PIN_P7E, 0u);
      
		// Enable Rx/Tx.        
        Mfs_Csio_EnableFunc(&CSIO12, CsioTx);
        Mfs_Csio_EnableFunc(&CSIO12, CsioRx);

		// Send command to change mode.        
        u16Data = (0x01u << 9)		// Mode control command.
					 | (0u << 8)		// R/O = 0 (read and write)
					 | (uint16_t)m;		// Mode.

        while (TRUE != Mfs_Csio_GetStatus(&CSIO12, CsioTxEmpty)); // wait until TX buffer empty 
        Mfs_Csio_SendData(&CSIO12, u16Data, TRUE);  
        
        // Wait until master TX bus idle
        while (TRUE != Mfs_Csio_GetStatus(&CSIO12, CsioTxIdle));
        
		// Disable Rx/Tx.        
        Mfs_Csio_DisableFunc(&CSIO12, CsioTx);
        Mfs_Csio_DisableFunc(&CSIO12, CsioRx);

        // CS = H
        Gpio1pin_Put(GPIO1PIN_P7E, 1u);
	}
}
Ejemplo n.º 2
0
/*!
 ******************************************************************************
 ** \brief  Polling the IO (P61)
 **
 ** \param  none
 **
 ** \return none
 ******************************************************************************
 */
void IoPolling(void)
{
    /* ignore first trigger in order to synchronize with PCLK*/
    if(!m_u16ValidFlag)
    {
        m_u16ValidFlag++;
        return;
    }
    m_u16ValidFlag++;
    Gpio1pin_Put(GPIO1PIN_P61, (m_u16ValidFlag%2));
    return;
}
Ejemplo n.º 3
0
/******************************************************************************
 ** \brief Wait CAN FD transceiver start
 **
 ** Wait until correct ID was read from the CAN FD transceiver.
 ** Identification register (0x7E) holds the device ID as follows;
 **   Device ID : 70h TJA1145T, TJA1145TK
 **               74h TJA1145T/FD, TJA1145TK/FD
 ** The transceiver on the target environment is TJA1145T/FD(ID=0x74).
 **
 ** \param [in] c                     CAN FD channel number (0-).
 ******************************************************************************/
static void CanfdDriverWait(uint8_t c)
{
    uint16_t u16Data;
	// Check parameter.
	if (c == 0)
	{
        // CS = L
        Gpio1pin_Put(GPIO1PIN_P7E, 0u);
      
		// Enable Rx/Tx.
        Mfs_Csio_EnableFunc(&CSIO12, CsioTx);
        Mfs_Csio_EnableFunc(&CSIO12, CsioRx);

		do {
			// Set data count.
            u16Data = (0x7Eul << 9)		// Get ID commnad
					   | (1ul << 8)	    // R/O = 1 (read only)
					   | 0ul;           // Don't care
          
			// Send command to read ID (ReadOnly).
            while (TRUE != Mfs_Csio_GetStatus(&CSIO12, CsioTxEmpty)); // wait until TX buffer empty 
            Mfs_Csio_SendData(&CSIO12, u16Data, TRUE);  
            
            // Wait until master TX bus idle
            while (TRUE != Mfs_Csio_GetStatus(&CSIO12, CsioTxIdle));
           
		// Check obtained ID.
		} while ((Mfs_Csio_ReceiveData(&CSIO12) & 0xFFul) != 0x74u);
        
		// Disable Rx/Tx.        
        Mfs_Csio_DisableFunc(&CSIO12, CsioTx);
        Mfs_Csio_DisableFunc(&CSIO12, CsioRx);
        
        // CS = H
        Gpio1pin_Put(GPIO1PIN_P7E, 1u);
	}
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: zigaobj/MCU
static void my_gpio_test(void)
{
	// GPIO Pin Init Output
	Gpio1pin_InitOut( GPIO1PIN_P30, Gpio1pin_InitVal( 0u ) );	// Init Output P30,Output Value: 0

	Gpio1pin_InitOut( GPIO1PIN_P31, Gpio1pin_InitVal( 0u ) );	// Init Output P31,Output Value: 0
	// GPIO Output Value change
	Gpio1pin_Put( GPIO1PIN_P31, 1u);                              // Output P31, Value: 1

	//	GPIO1PIN_P32; GPIO1PIN_NP32, inverted; 
	Gpio1pin_InitOut( GPIO1PIN_NP32, Gpio1pin_InitVal( 0u ) );    // Init inverted Output P52, Value: 0
	Gpio1pin_Put( GPIO1PIN_NP32, 1u);                             // Output inverted P52, Value: 1
	//输出反向, 配置1u, 实则输出低电平;

	// gpio PIN INIT INPUT
	Gpio1pin_InitIn ( GPIO1PIN_P51, Gpio1pin_InitPullup( 0u ) );  // Init Input P51
	if (1u == Gpio1pin_Get( GPIO1PIN_P51 ))                       // Read P51
	{}

	// gpio pin init input (invert port) 
	Gpio1pin_InitIn ( GPIO1PIN_NP53, Gpio1pin_InitPullup( 0u ) ); // Init inverted Input P53
	if (1u == Gpio1pin_Get( GPIO1PIN_NP53 ))                      // Read inverted P53
	{}

	//Pin Function Config
	//SetPinFunc_INT11_1(0u); 	// Pin Function: INT11_0

	// -----------

	// Straight forward port names
	GpioInitIn(P33, 0u);
	GpioGet(P00);

	GpioInitOut(P34, 0u);
	GpioPut(P34, 1u);
}