⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_at91m55800a_h.html

📁 eb55评估板例程 for ads
💻 HTML
📖 第 1 页 / 共 5 页
字号:
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> cpol,        <font color=#B22222>// \arg <a href="AT91M55800A_SPI.html#SPI">SPI</a> CPOL</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> ncpha)       <font color=#B22222>// \arg <a href="AT91M55800A_SPI.html#SPI">SPI</a> NCPHA</font>
{
    <font color=#B22222>//* Define the Communication baudrate</font>
    <a href="#AT91F_SPI_SetBaudrate">AT91F_SPI_SetBaudrate</a> (pSPI, CS_number, mainClock, baudRate);

    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[CS_number] = (pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[CS_number] & 0xFFFFFF0C) | (char_length | cpol | ncpha);

}



<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_Slave_Configure">AT91F_SPI_Slave_Configure</a></b></font>
<font color=#B22222>//* \brief Configure <a href="AT91M55800A_SPI.html#SPI">SPI</a> in Slave Mode</font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_Slave_Configure">AT91F_SPI_Slave_Configure</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI,         <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> com_parameter )    <font color=#B22222>// \arg chip_select_<font color=#0000FF>register</font> value</font>
{
    <font color=#B22222>//* Disable interrupts</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_IDR">SPI_IDR</a> = (<font color=#0000FF>unsigned</font> <font color=#0000FF>int</font>) -1;

    <font color=#B22222>//* Disable the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIDIS">AT91C_SPI_SPIDIS</a>;

    <font color=#B22222>//* Reset the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SWRST">AT91C_SPI_SWRST</a>;


    <font color=#B22222>//* Define the Communication protocole</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[0] = com_parameter;


    <font color=#B22222>//* Clear Transmit and Receive Counters</font>
    <a href="#AT91F_PDC_Open">AT91F_PDC_Open</a>((<a href="AT91M55800A_h.html#AT91PS_PDC">AT91PS_PDC</a>) &(pSPI->SPI_RPR));

    <font color=#B22222>//* Define the <a href="AT91M55800A_SPI.html#SPI">SPI</a> in slave mode</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_MR">SPI_MR</a> &= ~(<a href="AT91M55800A_h.html#AT91C_SPI_MSTR">AT91C_SPI_MSTR</a>);

}

<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_SimpleMaster_Configure">AT91F_SPI_SimpleMaster_Configure</a></b></font>
<font color=#B22222>//* \brief Configure <a href="AT91M55800A_SPI.html#SPI">SPI</a> in Master Mode with one chip select</font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_SimpleMaster_Configure">AT91F_SPI_SimpleMaster_Configure</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI,         <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> mainClock,  <font color=#B22222>// \arg peripheral clock</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> baudRate ,  <font color=#B22222>// \arg baudrate to be programmed</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> com_parameter )    <font color=#B22222>// \arg chip_select_<font color=#0000FF>register</font> value</font>
{
    <font color=#B22222>//* Disable interrupts</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_IDR">SPI_IDR</a> = (<font color=#0000FF>unsigned</font> <font color=#0000FF>int</font>) -1;

    <font color=#B22222>//* Disable the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIDIS">AT91C_SPI_SPIDIS</a>;

    <font color=#B22222>//* Reset the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SWRST">AT91C_SPI_SWRST</a>;


    <font color=#B22222>//* Define the Communication protocole : character length, cpol,cpha</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[0] = com_parameter;

    <font color=#B22222>//* Define the Communication baudrate</font>
    <a href="#AT91F_SPI_SetBaudrate">AT91F_SPI_SetBaudrate</a> (pSPI, 0, mainClock, baudRate);


    <font color=#B22222>//* Clear Transmit and Receive Counters</font>
    <a href="#AT91F_PDC_Open">AT91F_PDC_Open</a>((<a href="AT91M55800A_h.html#AT91PS_PDC">AT91PS_PDC</a>) &(pSPI->SPI_RPR));

    <font color=#B22222>//* Define the <a href="AT91M55800A_SPI.html#SPI">SPI</a> in master mode</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_MR">SPI_MR</a> |= <a href="AT91M55800A_h.html#AT91C_SPI_MSTR">AT91C_SPI_MSTR</a>;

}


<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_MultiMaster_Configure">AT91F_SPI_MultiMaster_Configure</a></b></font>
<font color=#B22222>//* \brief Configure <a href="AT91M55800A_SPI.html#SPI">SPI</a> in Master Mode with many chip selects available</font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_MultiMaster_Configure">AT91F_SPI_MultiMaster_Configure</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI,         <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> mainClock,  <font color=#B22222>// \arg peripheral clock</font>
        <font color=#0000FF>unsigned</font> <font color=#0000FF>int</font> baudRate)   <font color=#B22222>// \arg baudrate to be programmed</font>
{
    <font color=#B22222>//* Disable interrupts</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_IDR">SPI_IDR</a> = (<font color=#0000FF>unsigned</font> <font color=#0000FF>int</font>) -1;

    <font color=#B22222>//* Disable the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIDIS">AT91C_SPI_SPIDIS</a>;

    <font color=#B22222>//* Reset the <a href="AT91M55800A_SPI.html#SPI">SPI</a></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SWRST">AT91C_SPI_SWRST</a>;

    <font color=#B22222>//* Clear Transmit and Receive Counters</font>
    <a href="#AT91F_PDC_Open">AT91F_PDC_Open</a>((<a href="AT91M55800A_h.html#AT91PS_PDC">AT91PS_PDC</a>) &(pSPI->SPI_RPR));

    <font color=#B22222>//* Define the <a href="AT91M55800A_SPI.html#SPI">SPI</a> in variable master mode</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_MR">SPI_MR</a> |= (<a href="AT91M55800A_h.html#AT91C_SPI_MSTR">AT91C_SPI_MSTR</a> | <a href="AT91M55800A_h.html#AT91C_SPI_PS_VARIABLE">AT91C_SPI_PS_VARIABLE</a>);

}


<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_EnableTransfert">AT91F_SPI_EnableTransfert</a></b></font>
<font color=#B22222>//* \brief Enable the <a href="AT91M55800A_SPI.html#SPI">SPI</a> transfert</font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_EnableTransfert">AT91F_SPI_EnableTransfert</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI)     <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
{
    <font color=#B22222>//* Enable the transfert</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIEN">AT91C_SPI_SPIEN</a>;
}



<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_DisableTransfert">AT91F_SPI_DisableTransfert</a></b></font>
<font color=#B22222>//* \brief Disable the <a href="AT91M55800A_SPI.html#SPI">SPI</a> transfert</font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_DisableTransfert">AT91F_SPI_DisableTransfert</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI)     <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
{
    <font color=#B22222>//* Enable the transfert</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIDIS">AT91C_SPI_SPIDIS</a>;
}


<font color=#B22222>//*----------------------------------------------------------------------------</font>
<font color=#B22222>//* \fn    <b><a name="AT91F_SPI_Close">AT91F_SPI_Close</a></b></font>
<font color=#B22222>//* \brief Close <a href="AT91M55800A_SPI.html#SPI">SPI</a>: disable IT disable transfert, close <a href="AT91M55800A_PDC.html#PDC">PDC</a></font>
<font color=#B22222>//*----------------------------------------------------------------------------</font>
__inline <font color=#0000FF>void</font> <a href="#AT91F_SPI_Close">AT91F_SPI_Close</a> (
        <a href="AT91M55800A_h.html#AT91PS_SPI">AT91PS_SPI</a> pSPI)     <font color=#B22222>// \arg pointer to a <a href="AT91M55800A_SPI.html#SPI">SPI</a> controller</font>
{
    <font color=#B22222>//* Reset all the Chip Select <font color=#0000FF>register</font></font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[0] = 0 ;
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[1] = 0 ;
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[2] = 0 ;
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CSR">SPI_CSR</a>[3] = 0 ;

    <font color=#B22222>//* Reset the <a href="AT91M55800A_SPI.html#SPI">SPI</a> mode</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_MR">SPI_MR</a> = 0  ;


    <font color=#B22222>//* Disable all interrupts</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_IDR">SPI_IDR</a> = 0xFFFFFFFF ;

    <font color=#B22222>//* Abort the Peripheral Data Transfers</font>
    <a href="#AT91F_PDC_Close">AT91F_PDC_Close</a>((<a href="AT91M55800A_h.html#AT91PS_PDC">AT91PS_PDC</a>) &(pSPI->SPI_RPR));

    <font color=#B22222>//* Disable receiver and transmitter and stop any activity immediately</font>
    pSPI-><a href="AT91M55800A_SPI.html#SPI_CR">SPI_CR</a> = <a href="AT91M55800A_h.html#AT91C_SPI_SPIDIS">AT91C_SPI_SPIDIS</a>;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -