TCAN4550  1p2
TCAN4x5x_SPI.h
Go to the documentation of this file.
1 /*
2  * TCAN4x5x_SPI.h
3  * Version 2.0
4  * Description: This file is responsible for abstracting the lower-level microcontroller SPI read and write functions
5  *
6  * Created on: Oct 1, 2017
7  * Author: Texas Instruments
8  *
9  * Changelist:
10  * - 2.0: 05/03/2018
11  * - Updated pinout for boosterback support
12  *
13  * Copyright (c) 2017 Texas Instruments Incorporated. All rights reserved.
14  * Software License Agreement
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  *
20  * Redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer.
22  *
23  * Redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the
26  * distribution.
27  *
28  * Neither the name of Texas Instruments Incorporated nor the names of
29  * its contributors may be used to endorse or promote products derived
30  * from this software without specific prior written permission.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
40  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
42  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  */
44 #ifndef TCAN4X5X_SPI_H_
45 #define TCAN4X5X_SPI_H_
46 
47 #include <driverlib.h>
48 
49 // Defines for GPIO port and pin for MSP430 SPI port.
50 #define SPI_CS_GPIO_PORT GPIO_PORT_P2
51 #define SPI_CS_GPIO_PIN GPIO_PIN5
52 #define SPI_HW_ADDR EUSCI_B0_BASE
53 // MSP430 Specific commands to proper sequencing on the SPI bus
54 #define WAIT_FOR_TRANSMIT while (!(HWREG16(SPI_HW_ADDR + OFS_UCBxIFG) & UCTXIFG))
55 #define WAIT_FOR_IDLE while ((HWREG16(SPI_HW_ADDR + OFS_UCBxSTATW) & UCBUSY))
56 
57 
58 //------------------------------------------------------------------------
59 // AHB Access Op Codes
60 //------------------------------------------------------------------------
61 #define AHB_WRITE_OPCODE 0x61
62 #define AHB_READ_OPCODE 0x41
63 
64 
65 
66 
67 //------------------------------------------------------------------------
68 // Write Functions
69 //------------------------------------------------------------------------
70 
71 void AHB_WRITE_32(uint16_t address, uint32_t data);
72 void AHB_WRITE_BURST_START(uint16_t address, uint8_t words);
73 void AHB_WRITE_BURST_WRITE(uint32_t data);
74 void AHB_WRITE_BURST_END(void);
75 
76 
77 //--------------------------------------------------------------------------
78 // Read Functions
79 //--------------------------------------------------------------------------
80 uint32_t AHB_READ_32(uint16_t address);
81 void AHB_READ_BURST_START(uint16_t address, uint8_t words);
82 uint32_t AHB_READ_BURST_READ(void);
83 void AHB_READ_BURST_END(void);
84 
85 #endif
void AHB_READ_BURST_START(uint16_t address, uint8_t words)
Definition: TCAN4x5x_SPI.c:155
uint32_t AHB_READ_32(uint16_t address)
Definition: TCAN4x5x_SPI.c:66
uint32_t AHB_READ_BURST_READ(void)
Definition: TCAN4x5x_SPI.c:183
void AHB_WRITE_BURST_END(void)
Definition: TCAN4x5x_SPI.c:138
void AHB_READ_BURST_END(void)
Definition: TCAN4x5x_SPI.c:223
void AHB_WRITE_BURST_WRITE(uint32_t data)
Definition: TCAN4x5x_SPI.c:118
void AHB_WRITE_BURST_START(uint16_t address, uint8_t words)
Definition: TCAN4x5x_SPI.c:88
void AHB_WRITE_32(uint16_t address, uint32_t data)
Definition: TCAN4x5x_SPI.c:50