This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430g系列 USI 模块 SPI 模式请问底层函数

请问官方有给出msp430g系列 USI模块的SPI底层函数代码吗?我想深入学习一下430的spi.

  • 我们有官方例程可以供您参考,里面提供了一些函数

    dev.ti.com/.../node
  • msp430g系列是没有库函数的,都是直接操作寄存器。所以官网的例程没有所谓底层函数的说法。

    上传两个例程,你参考下

    msp430g2xx3_usci_spi_standard_slave.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    //******************************************************************************
    // MSP430G2xx3 Demo - USCI_A0, SPI 3-Wire Slave multiple byte RX/TX
    //
    // Description: SPI master communicates to SPI slave sending and receiving
    // 3 different messages of different length. SPI slave will enter LPM0
    // while waiting for the messages to be sent/receiving using SPI interrupt.
    // ACLK = NA, MCLK = SMCLK = DCO 16MHz.
    //
    //
    // MSP430G2553
    // -----------------
    // /|\ | P2.0|<- Master's GPIO (Chip Select)
    // | | |
    // ---|RST RST |<- Master's GPIO (To reset slave)
    // | |
    // | P1.2|<- Data In (UCA0SIMO)
    // | |
    // | P1.1|-> Data Out (UCA0SOMI)
    // | |
    // | P1.4|<- Serial Clock In (UCA0CLK)
    //
    // Nima Eskandari
    // Texas Instruments Inc.
    // April 2017
    // Built with CCS V7.0
    //******************************************************************************
    #include <msp430.h>
    #include <stdint.h>
    //******************************************************************************
    // Example Commands ************************************************************
    //******************************************************************************
    #define DUMMY 0xFF
    #define SLAVE_CS_IN P2IN
    #define SLAVE_CS_DIR P2DIR
    #define SLAVE_CS_PIN BIT0
    /* CMD_TYPE_X_SLAVE are example commands the master sends to the slave.
    * The slave will send example SlaveTypeX buffers in response.
    *
    * CMD_TYPE_X_MASTER are example commands the master sends to the slave.
    * The slave will initialize itself to receive MasterTypeX example buffers.
    * */
    #define CMD_TYPE_0_SLAVE 0
    #define CMD_TYPE_1_SLAVE 1
    #define CMD_TYPE_2_SLAVE 2
    #define CMD_TYPE_0_MASTER 3
    #define CMD_TYPE_1_MASTER 4
    #define CMD_TYPE_2_MASTER 5
    #define TYPE_0_LENGTH 1
    #define TYPE_1_LENGTH 2
    #define TYPE_2_LENGTH 6
    #define MAX_BUFFER_SIZE 20
    /* MasterTypeX are example buffers initialized in the master, they will be
    * sent by the master to the slave.
    * SlaveTypeX are example buffers initialized in the slave, they will be
    * sent by the slave to the master.
    * */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    msp430g2xx3_usci_spi_standard_master.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    //******************************************************************************
    // MSP430G2xx3 Demo - USCI_A0, SPI 3-Wire Master multiple byte RX/TX
    //
    // Description: SPI master communicates to SPI slave sending and receiving
    // 3 different messages of different length. SPI master will enter LPM0 mode
    // while waiting for the messages to be sent/receiving using SPI interrupt.
    // SPI Master will initially wait for a port interrupt in LPM0 mode before
    // starting the SPI communication.
    // ACLK = NA, MCLK = SMCLK = DCO 16MHz.
    //
    //
    // MSP430G2553
    // -----------------
    // /|\ | P2.0|-> Slave Chip Select (GPIO)
    // | | |
    // ---|RST P1.5|-> Slave Reset (GPIO)
    // | |
    // | P1.2|-> Data Out (UCA0SIMO)
    // | |
    // Button ->|P1.3 P1.1|<- Data In (UCA0SOMI)
    // | |
    // | P1.4|-> Serial Clock Out (UCA0CLK)
    //
    // Nima Eskandari
    // Texas Instruments Inc.
    // April 2017
    // Built with CCS V7.0
    //******************************************************************************
    #include <msp430.h>
    #include <stdint.h>
    //******************************************************************************
    // Example Commands ************************************************************
    //******************************************************************************
    #define DUMMY 0xFF
    #define SLAVE_CS_OUT P2OUT
    #define SLAVE_CS_DIR P2DIR
    #define SLAVE_CS_PIN BIT0
    /* CMD_TYPE_X_SLAVE are example commands the master sends to the slave.
    * The slave will send example SlaveTypeX buffers in response.
    *
    * CMD_TYPE_X_MASTER are example commands the master sends to the slave.
    * The slave will initialize itself to receive MasterTypeX example buffers.
    * */
    #define CMD_TYPE_0_SLAVE 0
    #define CMD_TYPE_1_SLAVE 1
    #define CMD_TYPE_2_SLAVE 2
    #define CMD_TYPE_0_MASTER 3
    #define CMD_TYPE_1_MASTER 4
    #define CMD_TYPE_2_MASTER 5
    #define TYPE_0_LENGTH 1
    #define TYPE_1_LENGTH 2
    #define TYPE_2_LENGTH 6
    #define MAX_BUFFER_SIZE 20
    /* MasterTypeX are example buffers initialized in the master, they will be
    * sent by the master to the slave.
    * SlaveTypeX are example buffers initialized in the slave, they will be
    * sent by the slave to the master.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

x 出现错误。请重试或与管理员联系。