2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <interrupt.h>
42 static bool is_A_Module(uint32_t module)
44 if (module == EUSCI_A0_MODULE || module == EUSCI_A1_MODULE
45 #ifdef EUSCI_A2_MODULE
46 || module == EUSCI_A2_MODULE
48 #ifdef EUSCI_A3_MODULE
49 || module == EUSCI_A3_MODULE
57 bool SPI_initMaster(uint32_t moduleInstance, const eUSCI_SPI_MasterConfig *config)
59 if (is_A_Module(moduleInstance))
62 (EUSCI_A_SPI_CLOCKSOURCE_ACLK == config->selectClockSource)
63 || (EUSCI_A_SPI_CLOCKSOURCE_SMCLK
64 == config->selectClockSource));
67 (EUSCI_A_SPI_MSB_FIRST == config->msbFirst)
68 || (EUSCI_A_SPI_LSB_FIRST == config->msbFirst));
71 (EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
72 == config->clockPhase)
73 || (EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
74 == config->clockPhase));
77 (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
78 == config->clockPolarity)
79 || (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW
80 == config->clockPolarity));
83 (EUSCI_A_SPI_3PIN == config->spiMode)
84 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH
86 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW
89 //Disable the USCI Module
90 BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r, UCSWRST_OFS) = 1;
93 * Configure as SPI master mode.
94 * Clock phase select, polarity, msb
96 * UCSYNC = Synchronous mode
97 * UCMODE_0 = 3-pin SPI
99 EUSCI_A_CMSIS(moduleInstance)->rCTLW0.r =
100 (EUSCI_A_CMSIS(moduleInstance)->rCTLW0.r
101 & ~(UCSSEL_3 + UCCKPH + UCCKPL + UC7BIT + UCMSB + UCMST
102 + UCMODE_3 + UCSYNC))
103 | (config->selectClockSource + config->msbFirst
104 + config->clockPhase + config->clockPolarity
105 + UCMST + UCSYNC + config->spiMode);
107 EUSCI_A_CMSIS(moduleInstance)->rBRW =
108 (uint16_t) (config->clockSourceFrequency
109 / config->desiredSpiClock);
112 EUSCI_A_CMSIS(moduleInstance)->rMCTLW.r = 0;
118 (EUSCI_B_SPI_CLOCKSOURCE_ACLK == config->selectClockSource)
119 || (EUSCI_B_SPI_CLOCKSOURCE_SMCLK
120 == config->selectClockSource));
123 (EUSCI_B_SPI_MSB_FIRST == config->msbFirst)
124 || (EUSCI_B_SPI_LSB_FIRST == config->msbFirst));
127 (EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
128 == config->clockPhase)
129 || (EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
130 == config->clockPhase));
133 (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
134 == config->clockPolarity)
135 || (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW
136 == config->clockPolarity));
139 (EUSCI_B_SPI_3PIN == config->spiMode)
140 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
142 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW
143 == config->spiMode));
145 //Disable the USCI Module
146 BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r, UCSWRST_OFS) = 1;
149 * Configure as SPI master mode.
150 * Clock phase select, polarity, msb
151 * UCMST = Master mode
152 * UCSYNC = Synchronous mode
153 * UCMODE_0 = 3-pin SPI
155 EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r =
156 (EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r
157 & ~(UCSSEL_3 + UCCKPH + UCCKPL + UC7BIT + UCMSB + UCMST
158 + UCMODE_3 + UCSYNC))
159 | (config->selectClockSource + config->msbFirst
160 + config->clockPhase + config->clockPolarity
161 + UCMST + UCSYNC + config->spiMode);
163 EUSCI_B_CMSIS(moduleInstance)->rBRW =
164 (uint16_t) (config->clockSourceFrequency
165 / config->desiredSpiClock);
172 void SPI_selectFourPinFunctionality(uint32_t moduleInstance,
173 uint_fast8_t select4PinFunctionality)
175 if (is_A_Module(moduleInstance))
177 EUSCI_A_SPI_select4PinFunctionality(moduleInstance,
178 select4PinFunctionality);
181 EUSCI_B_SPI_select4PinFunctionality(moduleInstance,
182 select4PinFunctionality);
187 void SPI_changeMasterClock(uint32_t moduleInstance,
188 uint32_t clockSourceFrequency, uint32_t desiredSpiClock)
190 if (is_A_Module(moduleInstance))
192 EUSCI_A_SPI_masterChangeClock(moduleInstance, clockSourceFrequency,
196 EUSCI_B_SPI_masterChangeClock(moduleInstance, clockSourceFrequency,
202 bool SPI_initSlave(uint32_t moduleInstance, const eUSCI_SPI_SlaveConfig *config)
204 if (is_A_Module(moduleInstance))
207 (EUSCI_A_SPI_MSB_FIRST == config->msbFirst)
208 || (EUSCI_A_SPI_LSB_FIRST == config->msbFirst));
211 (EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
212 == config->clockPhase)
213 || (EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
214 == config->clockPhase));
217 (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
218 == config->clockPolarity)
219 || (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW
220 == config->clockPolarity));
223 (EUSCI_A_SPI_3PIN == config->spiMode)
224 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH
226 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW
227 == config->spiMode));
229 //Disable USCI Module
230 BITBAND_PERI(EUSCI_A_CMSIS(moduleInstance)->rCTLW0.r, UCSWRST_OFS) = 1;
232 //Reset OFS_UCAxCTLW0 register
233 EUSCI_A_CMSIS(moduleInstance)->rCTLW0.r =
234 (EUSCI_A_CMSIS(moduleInstance)->rCTLW0.r
235 & ~(UCMSB + UC7BIT + UCMST + UCCKPL + UCCKPH + UCMODE_3))
236 | (config->clockPhase + config->clockPolarity
237 + config->msbFirst + UCSYNC + config->spiMode);
243 (EUSCI_B_SPI_MSB_FIRST == config->msbFirst)
244 || (EUSCI_B_SPI_LSB_FIRST == config->msbFirst));
247 (EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
248 == config->clockPhase)
249 || (EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
250 == config->clockPhase));
253 (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
254 == config->clockPolarity)
255 || (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW
256 == config->clockPolarity));
259 (EUSCI_B_SPI_3PIN == config->spiMode)
260 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
262 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW
263 == config->spiMode));
265 //Disable USCI Module
266 BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r, UCSWRST_OFS) = 1;
268 //Reset OFS_UCBxCTLW0 register
269 EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r =
270 (EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r
271 & ~(UCMSB + UC7BIT + UCMST + UCCKPL + UCCKPH + UCMODE_3))
272 | (config->clockPhase + config->clockPolarity
273 + config->msbFirst + UCSYNC + config->spiMode);
280 void SPI_changeClockPhasePolarity(uint32_t moduleInstance,
281 uint_fast16_t clockPhase, uint_fast16_t clockPolarity)
283 if (is_A_Module(moduleInstance))
285 EUSCI_A_SPI_changeClockPhasePolarity(moduleInstance, clockPhase,
289 EUSCI_B_SPI_changeClockPhasePolarity(moduleInstance, clockPhase,
295 void SPI_transmitData(uint32_t moduleInstance, uint_fast8_t transmitData)
297 if (is_A_Module(moduleInstance))
299 EUSCI_A_SPI_transmitData(moduleInstance, transmitData);
302 EUSCI_B_SPI_transmitData(moduleInstance, transmitData);
307 uint8_t SPI_receiveData(uint32_t moduleInstance)
309 if (is_A_Module(moduleInstance))
311 return EUSCI_A_SPI_receiveData(moduleInstance);
314 return EUSCI_B_SPI_receiveData(moduleInstance);
319 void SPI_enableModule(uint32_t moduleInstance)
321 if (is_A_Module(moduleInstance))
323 EUSCI_A_SPI_enable(moduleInstance);
326 EUSCI_B_SPI_enable(moduleInstance);
331 void SPI_disableModule(uint32_t moduleInstance)
333 if (is_A_Module(moduleInstance))
335 EUSCI_A_SPI_disable(moduleInstance);
338 EUSCI_B_SPI_disable(moduleInstance);
343 uint32_t SPI_getReceiveBufferAddressForDMA(uint32_t moduleInstance)
345 if (is_A_Module(moduleInstance))
347 return EUSCI_A_SPI_getReceiveBufferAddressForDMA(moduleInstance);
350 return EUSCI_B_SPI_getReceiveBufferAddressForDMA(moduleInstance);
355 uint32_t SPI_getTransmitBufferAddressForDMA(uint32_t moduleInstance)
357 if (is_A_Module(moduleInstance))
359 return EUSCI_A_SPI_getTransmitBufferAddressForDMA(moduleInstance);
362 return EUSCI_B_SPI_getTransmitBufferAddressForDMA(moduleInstance);
367 uint_fast8_t SPI_isBusy(uint32_t moduleInstance)
369 if (is_A_Module(moduleInstance))
371 return EUSCI_A_SPI_isBusy(moduleInstance);
374 return EUSCI_B_SPI_isBusy(moduleInstance);
379 void SPI_enableInterrupt(uint32_t moduleInstance, uint_fast8_t mask)
381 if (is_A_Module(moduleInstance))
383 EUSCI_A_SPI_enableInterrupt(moduleInstance, mask);
386 EUSCI_B_SPI_enableInterrupt(moduleInstance, mask);
391 void SPI_disableInterrupt(uint32_t moduleInstance, uint_fast8_t mask)
393 if (is_A_Module(moduleInstance))
395 EUSCI_A_SPI_disableInterrupt(moduleInstance, mask);
398 EUSCI_B_SPI_disableInterrupt(moduleInstance, mask);
403 uint_fast8_t SPI_getInterruptStatus(uint32_t moduleInstance, uint16_t mask)
405 if (is_A_Module(moduleInstance))
407 return EUSCI_A_SPI_getInterruptStatus(moduleInstance, mask);
410 return EUSCI_B_SPI_getInterruptStatus(moduleInstance, mask);
415 uint_fast8_t SPI_getEnabledInterruptStatus(uint32_t moduleInstance)
417 if (is_A_Module(moduleInstance))
419 return SPI_getInterruptStatus(moduleInstance,
420 EUSCI_SPI_TRANSMIT_INTERRUPT | EUSCI_SPI_RECEIVE_INTERRUPT)
421 & HWREG16(moduleInstance + OFS_UCA0IE);
424 return SPI_getInterruptStatus(moduleInstance,
425 EUSCI_SPI_TRANSMIT_INTERRUPT | EUSCI_SPI_RECEIVE_INTERRUPT)
426 & HWREG16(moduleInstance + OFS_UCB0IE);
431 void SPI_clearInterruptFlag(uint32_t moduleInstance, uint_fast8_t mask)
433 if (is_A_Module(moduleInstance))
435 EUSCI_A_SPI_clearInterruptFlag(moduleInstance, mask);
438 EUSCI_B_SPI_clearInterruptFlag(moduleInstance, mask);
443 void SPI_registerInterrupt(uint32_t moduleInstance, void (*intHandler)(void))
445 switch (moduleInstance)
447 case EUSCI_A0_MODULE:
448 Interrupt_registerInterrupt(INT_EUSCIA0, intHandler);
449 Interrupt_enableInterrupt(INT_EUSCIA0);
451 case EUSCI_A1_MODULE:
452 Interrupt_registerInterrupt(INT_EUSCIA1, intHandler);
453 Interrupt_enableInterrupt(INT_EUSCIA1);
455 #ifdef EUSCI_A2_MODULE
456 case EUSCI_A2_MODULE:
457 Interrupt_registerInterrupt(INT_EUSCIA2, intHandler);
458 Interrupt_enableInterrupt(INT_EUSCIA2);
461 #ifdef EUSCI_A3_MODULE
462 case EUSCI_A3_MODULE:
463 Interrupt_registerInterrupt(INT_EUSCIA3, intHandler);
464 Interrupt_enableInterrupt(INT_EUSCIA3);
467 case EUSCI_B0_MODULE:
468 Interrupt_registerInterrupt(INT_EUSCIB0, intHandler);
469 Interrupt_enableInterrupt(INT_EUSCIB0);
471 case EUSCI_B1_MODULE:
472 Interrupt_registerInterrupt(INT_EUSCIB1, intHandler);
473 Interrupt_enableInterrupt(INT_EUSCIB1);
475 #ifdef EUSCI_B2_MODULE
476 case EUSCI_B2_MODULE:
477 Interrupt_registerInterrupt(INT_EUSCIB2, intHandler);
478 Interrupt_enableInterrupt(INT_EUSCIB2);
481 #ifdef EUSCI_B3_MODULE
482 case EUSCI_B3_MODULE:
483 Interrupt_registerInterrupt(INT_EUSCIB3, intHandler);
484 Interrupt_enableInterrupt(INT_EUSCIB3);
492 void SPI_unregisterInterrupt(uint32_t moduleInstance)
494 switch (moduleInstance)
496 case EUSCI_A0_MODULE:
497 Interrupt_disableInterrupt(INT_EUSCIA0);
498 Interrupt_unregisterInterrupt(INT_EUSCIA0);
500 case EUSCI_A1_MODULE:
501 Interrupt_disableInterrupt(INT_EUSCIA1);
502 Interrupt_unregisterInterrupt(INT_EUSCIA1);
504 #ifdef EUSCI_A2_MODULE
505 case EUSCI_A2_MODULE:
506 Interrupt_disableInterrupt(INT_EUSCIA2);
507 Interrupt_unregisterInterrupt(INT_EUSCIA2);
510 #ifdef EUSCI_A3_MODULE
511 case EUSCI_A3_MODULE:
512 Interrupt_disableInterrupt(INT_EUSCIA3);
513 Interrupt_unregisterInterrupt(INT_EUSCIA3);
516 case EUSCI_B0_MODULE:
517 Interrupt_disableInterrupt(INT_EUSCIB0);
518 Interrupt_unregisterInterrupt(INT_EUSCIB0);
520 case EUSCI_B1_MODULE:
521 Interrupt_disableInterrupt(INT_EUSCIB1);
522 Interrupt_unregisterInterrupt(INT_EUSCIB1);
524 #ifdef EUSCI_B2_MODULE
525 case EUSCI_B2_MODULE:
526 Interrupt_disableInterrupt(INT_EUSCIB2);
527 Interrupt_unregisterInterrupt(INT_EUSCIB2);
530 #ifdef EUSCI_B3_MODULE
531 case EUSCI_B3_MODULE:
532 Interrupt_disableInterrupt(INT_EUSCIB3);
533 Interrupt_unregisterInterrupt(INT_EUSCIB3);
542 /* Backwards Compatibility Layer */
544 //*****************************************************************************
546 //! \brief Selects 4Pin Functionality
548 //! This function should be invoked only in 4-wire mode. Invoking this function
549 //! has no effect in 3-wire mode.
551 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
552 //! \param select4PinFunctionality selects 4 pin functionality
553 //! Valid values are:
554 //! - \b EUSCI_B_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
555 //! - \b EUSCI_B_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
557 //! Modified bits are \b UCSTEM of \b UCAxCTLW0 register.
561 //*****************************************************************************
562 void EUSCI_B_SPI_select4PinFunctionality(uint32_t baseAddress,
563 uint8_t select4PinFunctionality)
566 (EUSCI_B_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
567 == select4PinFunctionality)
568 || (EUSCI_B_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
569 == select4PinFunctionality));
571 EUSCI_B_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_B_CMSIS(baseAddress)->rCTLW0.r
572 & ~UCSTEM) | select4PinFunctionality;
575 //*****************************************************************************
577 //! \brief Initializes the SPI Master clock. At the end of this function call,
578 //! SPI module is left enabled.
580 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
581 //! \param clockSourceFrequency is the frequency of the slected clock source
582 //! \param desiredSpiClock is the desired clock rate for SPI communication
584 //! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
588 //*****************************************************************************
589 void EUSCI_B_SPI_masterChangeClock(uint32_t baseAddress,
590 uint32_t clockSourceFrequency, uint32_t desiredSpiClock)
592 //Disable the USCI Module
593 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
595 EUSCI_B_CMSIS(baseAddress)->rBRW = (uint16_t) (clockSourceFrequency
598 //Reset the UCSWRST bit to enable the USCI Module
599 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
602 //*****************************************************************************
604 //! \brief Initializes the SPI Slave block.
606 //! Upon successful initialization of the SPI slave block, this function will
607 //! have initailized the slave block, but the SPI Slave block still remains
608 //! disabled and must be enabled with EUSCI_B_SPI_enable()
610 //! \param baseAddress is the base address of the EUSCI_B_SPI Slave module.
611 //! \param msbFirst controls the direction of the receive and transmit shift
613 //! Valid values are:
614 //! - \b EUSCI_B_SPI_MSB_FIRST
615 //! - \b EUSCI_B_SPI_LSB_FIRST [Default]
616 //! \param clockPhase is clock phase select.
617 //! Valid values are:
618 //! - \b EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
620 //! - \b EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
621 //! \param clockPolarity is clock polarity select
622 //! Valid values are:
623 //! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
624 //! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
625 //! \param spiMode is SPI mode select
626 //! Valid values are:
627 //! - \b EUSCI_B_SPI_3PIN
628 //! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
629 //! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW
631 //! Modified bits are \b UCMSB, \b UCMST, \b UC7BIT, \b UCCKPL, \b UCCKPH, \b
632 //! UCMODE and \b UCSWRST of \b UCAxCTLW0 register.
634 //! \return STATUS_SUCCESS
636 //*****************************************************************************
637 bool EUSCI_B_SPI_slaveInit(uint32_t baseAddress, uint16_t msbFirst,
638 uint16_t clockPhase, uint16_t clockPolarity, uint16_t spiMode)
641 (EUSCI_B_SPI_MSB_FIRST == msbFirst)
642 || (EUSCI_B_SPI_LSB_FIRST == msbFirst));
645 (EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
647 || (EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
651 (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH == clockPolarity)
652 || (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW
656 (EUSCI_B_SPI_3PIN == spiMode)
657 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH == spiMode)
658 || (EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW == spiMode));
660 //Disable USCI Module
661 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
663 //Reset OFS_UCBxCTLW0 register
664 EUSCI_B_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_B_CMSIS(baseAddress)->rCTLW0.r
665 & ~(UCMSB + UC7BIT + UCMST + UCCKPL + UCCKPH + UCMODE_3))
666 | (clockPhase + clockPolarity + msbFirst + UCSYNC + spiMode);
671 //*****************************************************************************
673 //! \brief Changes the SPI colock phase and polarity. At the end of this
674 //! function call, SPI module is left enabled.
676 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
677 //! \param clockPhase is clock phase select.
678 //! Valid values are:
679 //! - \b EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
681 //! - \b EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
682 //! \param clockPolarity is clock polarity select
683 //! Valid values are:
684 //! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
685 //! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
687 //! Modified bits are \b UCCKPL, \b UCCKPH and \b UCSWRST of \b UCAxCTLW0
692 //*****************************************************************************
693 void EUSCI_B_SPI_changeClockPhasePolarity(uint32_t baseAddress,
694 uint16_t clockPhase, uint16_t clockPolarity)
698 (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH == clockPolarity)
699 || (EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW
703 (EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
705 || (EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
708 //Disable the USCI Module
709 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
711 EUSCI_B_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_B_CMSIS(baseAddress)->rCTLW0.r
712 & ~(UCCKPH + UCCKPL)) | (clockPhase + clockPolarity);
714 //Reset the UCSWRST bit to enable the USCI Module
715 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
718 //*****************************************************************************
720 //! \brief Transmits a byte from the SPI Module.
722 //! This function will place the supplied data into SPI trasmit data register
723 //! to start transmission.
725 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
726 //! \param transmitData data to be transmitted from the SPI module
730 //*****************************************************************************
731 void EUSCI_B_SPI_transmitData(uint32_t baseAddress, uint8_t transmitData)
733 EUSCI_B_CMSIS(baseAddress)->rTXBUF.r = transmitData;
736 //*****************************************************************************
738 //! \brief Receives a byte that has been sent to the SPI Module.
740 //! This function reads a byte of data from the SPI receive data Register.
742 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
744 //! \return Returns the byte received from by the SPI module, cast as an
747 //*****************************************************************************
748 uint8_t EUSCI_B_SPI_receiveData(uint32_t baseAddress)
750 return EUSCI_B_CMSIS(baseAddress)->rRXBUF.r;
753 //*****************************************************************************
755 //! \brief Enables individual SPI interrupt sources.
757 //! Enables the indicated SPI interrupt sources. Only the sources that are
758 //! enabled can be reflected to the processor interrupt; disabled sources have
759 //! no effect on the processor. Does not clear interrupt flags.
761 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
762 //! \param mask is the bit mask of the interrupt sources to be enabled.
763 //! Mask value is the logical OR of any of the following:
764 //! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
765 //! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
767 //! Modified bits of \b UCAxIFG register and bits of \b UCAxIE register.
771 //*****************************************************************************
772 void EUSCI_B_SPI_enableInterrupt(uint32_t baseAddress, uint8_t mask)
776 & ~(EUSCI_B_SPI_RECEIVE_INTERRUPT
777 | EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
779 EUSCI_B_CMSIS(baseAddress)->rIE.r |= mask;
782 //*****************************************************************************
784 //! \brief Disables individual SPI interrupt sources.
786 //! Disables the indicated SPI interrupt sources. Only the sources that are
787 //! enabled can be reflected to the processor interrupt; disabled sources have
788 //! no effect on the processor.
790 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
791 //! \param mask is the bit mask of the interrupt sources to be disabled.
792 //! Mask value is the logical OR of any of the following:
793 //! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
794 //! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
796 //! Modified bits of \b UCAxIE register.
800 //*****************************************************************************
801 void EUSCI_B_SPI_disableInterrupt(uint32_t baseAddress, uint8_t mask)
805 & ~(EUSCI_B_SPI_RECEIVE_INTERRUPT
806 | EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
808 EUSCI_B_CMSIS(baseAddress)->rIE.r &= ~mask;
811 //*****************************************************************************
813 //! \brief Gets the current SPI interrupt status.
815 //! This returns the interrupt status for the SPI module based on which flag is
818 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
819 //! \param mask is the masked interrupt flag status to be returned.
820 //! Mask value is the logical OR of any of the following:
821 //! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
822 //! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
824 //! \return Logical OR of any of the following:
825 //! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
826 //! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
827 //! \n indicating the status of the masked interrupts
829 //*****************************************************************************
830 uint8_t EUSCI_B_SPI_getInterruptStatus(uint32_t baseAddress, uint8_t mask)
834 & ~(EUSCI_B_SPI_RECEIVE_INTERRUPT
835 | EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
837 return EUSCI_B_CMSIS(baseAddress)->rIFG.r & mask;
840 //*****************************************************************************
842 //! \brief Clears the selected SPI interrupt status flag.
844 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
845 //! \param mask is the masked interrupt flag to be cleared.
846 //! Mask value is the logical OR of any of the following:
847 //! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
848 //! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
850 //! Modified bits of \b UCAxIFG register.
854 //*****************************************************************************
855 void EUSCI_B_SPI_clearInterruptFlag(uint32_t baseAddress, uint8_t mask)
859 & ~(EUSCI_B_SPI_RECEIVE_INTERRUPT
860 | EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
862 EUSCI_B_CMSIS(baseAddress)->rIFG.r &= ~mask;
865 //*****************************************************************************
867 //! \brief Enables the SPI block.
869 //! This will enable operation of the SPI block.
871 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
873 //! Modified bits are \b UCSWRST of \b UCBxCTLW0 register.
877 //*****************************************************************************
878 void EUSCI_B_SPI_enable(uint32_t baseAddress)
880 //Reset the UCSWRST bit to enable the USCI Module
881 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
884 //*****************************************************************************
886 //! \brief Disables the SPI block.
888 //! This will disable operation of the SPI block.
890 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
892 //! Modified bits are \b UCSWRST of \b UCBxCTLW0 register.
896 //*****************************************************************************
897 void EUSCI_B_SPI_disable(uint32_t baseAddress)
899 //Set the UCSWRST bit to disable the USCI Module
900 BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
903 //*****************************************************************************
905 //! \brief Returns the address of the RX Buffer of the SPI for the DMA module.
907 //! Returns the address of the SPI RX Buffer. This can be used in conjunction
908 //! with the DMA to store the received data directly to memory.
910 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
912 //! \return the address of the RX Buffer
914 //*****************************************************************************
915 uint32_t EUSCI_B_SPI_getReceiveBufferAddressForDMA(uint32_t baseAddress)
917 return baseAddress + OFS_UCB0RXBUF;
920 //*****************************************************************************
922 //! \brief Returns the address of the TX Buffer of the SPI for the DMA module.
924 //! Returns the address of the SPI TX Buffer. This can be used in conjunction
925 //! with the DMA to obtain transmitted data directly from memory.
927 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
929 //! \return the address of the TX Buffer
931 //*****************************************************************************
932 uint32_t EUSCI_B_SPI_getTransmitBufferAddressForDMA(uint32_t baseAddress)
934 return baseAddress + OFS_UCB0TXBUF;
937 //*****************************************************************************
939 //! \brief Indicates whether or not the SPI bus is busy.
941 //! This function returns an indication of whether or not the SPI bus is
942 //! busy.This function checks the status of the bus via UCBBUSY bit
944 //! \param baseAddress is the base address of the EUSCI_B_SPI module.
946 //! \return true if busy, false otherwise
948 //*****************************************************************************
949 bool EUSCI_B_SPI_isBusy(uint32_t baseAddress)
951 //Return the bus busy status.
952 return BITBAND_PERI(EUSCI_B_CMSIS(baseAddress)->rSTATW.r, UCBBUSY_OFS);
955 //*****************************************************************************
957 //! \brief Selects 4Pin Functionality
959 //! This function should be invoked only in 4-wire mode. Invoking this function
960 //! has no effect in 3-wire mode.
962 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
963 //! \param select4PinFunctionality selects 4 pin functionality
964 //! Valid values are:
965 //! - \b EUSCI_A_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
966 //! - \b EUSCI_A_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
968 //! Modified bits are \b UCSTEM of \b UCAxCTLW0 register.
972 //*****************************************************************************
973 void EUSCI_A_SPI_select4PinFunctionality(uint32_t baseAddress,
974 uint8_t select4PinFunctionality)
977 (EUSCI_A_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
978 == select4PinFunctionality)
979 || (EUSCI_A_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
980 == select4PinFunctionality));
982 EUSCI_A_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_A_CMSIS(baseAddress)->rCTLW0.r
983 & ~UCSTEM) | select4PinFunctionality;
986 //*****************************************************************************
988 //! \brief Initializes the SPI Master clock. At the end of this function call,
989 //! SPI module is left enabled.
991 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
992 //! \param clockSourceFrequency is the frequency of the slected clock source
993 //! \param desiredSpiClock is the desired clock rate for SPI communication
995 //! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
999 //*****************************************************************************
1000 void EUSCI_A_SPI_masterChangeClock(uint32_t baseAddress,
1001 uint32_t clockSourceFrequency, uint32_t desiredSpiClock)
1003 //Disable the USCI Module
1004 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
1006 EUSCI_A_CMSIS(baseAddress)->rBRW = (uint16_t) (clockSourceFrequency
1009 //Reset the UCSWRST bit to enable the USCI Module
1010 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
1013 //*****************************************************************************
1015 //! \brief Initializes the SPI Slave block.
1017 //! Upon successful initialization of the SPI slave block, this function will
1018 //! have initailized the slave block, but the SPI Slave block still remains
1019 //! disabled and must be enabled with EUSCI_A_SPI_enable()
1021 //! \param baseAddress is the base address of the EUSCI_A_SPI Slave module.
1022 //! \param msbFirst controls the direction of the receive and transmit shift
1024 //! Valid values are:
1025 //! - \b EUSCI_A_SPI_MSB_FIRST
1026 //! - \b EUSCI_A_SPI_LSB_FIRST [Default]
1027 //! \param clockPhase is clock phase select.
1028 //! Valid values are:
1029 //! - \b EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
1031 //! - \b EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
1032 //! \param clockPolarity is clock polarity select
1033 //! Valid values are:
1034 //! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
1035 //! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
1036 //! \param spiMode is SPI mode select
1037 //! Valid values are:
1038 //! - \b EUSCI_A_SPI_3PIN
1039 //! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH
1040 //! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW
1042 //! Modified bits are \b UCMSB, \b UCMST, \b UC7BIT, \b UCCKPL, \b UCCKPH, \b
1043 //! UCMODE and \b UCSWRST of \b UCAxCTLW0 register.
1045 //! \return STATUS_SUCCESS
1047 //*****************************************************************************
1048 bool EUSCI_A_SPI_slaveInit(uint32_t baseAddress, uint16_t msbFirst,
1049 uint16_t clockPhase, uint16_t clockPolarity, uint16_t spiMode)
1052 (EUSCI_A_SPI_MSB_FIRST == msbFirst)
1053 || (EUSCI_A_SPI_LSB_FIRST == msbFirst));
1056 (EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
1058 || (EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
1062 (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH == clockPolarity)
1063 || (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW
1067 (EUSCI_A_SPI_3PIN == spiMode)
1068 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH == spiMode)
1069 || (EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW == spiMode));
1071 //Disable USCI Module
1072 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
1074 //Reset OFS_UCAxCTLW0 register
1075 EUSCI_A_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_A_CMSIS(baseAddress)->rCTLW0.r
1076 & ~(UCMSB + UC7BIT + UCMST + UCCKPL + UCCKPH + UCMODE_3))
1077 | (clockPhase + clockPolarity + msbFirst + UCSYNC + spiMode);
1082 //*****************************************************************************
1084 //! \brief Changes the SPI colock phase and polarity. At the end of this
1085 //! function call, SPI module is left enabled.
1087 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1088 //! \param clockPhase is clock phase select.
1089 //! Valid values are:
1090 //! - \b EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
1092 //! - \b EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
1093 //! \param clockPolarity is clock polarity select
1094 //! Valid values are:
1095 //! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
1096 //! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
1098 //! Modified bits are \b UCCKPL, \b UCCKPH and \b UCSWRST of \b UCAxCTLW0
1103 //*****************************************************************************
1104 void EUSCI_A_SPI_changeClockPhasePolarity(uint32_t baseAddress,
1105 uint16_t clockPhase, uint16_t clockPolarity)
1109 (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH == clockPolarity)
1110 || (EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW
1114 (EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
1116 || (EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
1119 //Disable the USCI Module
1120 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
1122 EUSCI_A_CMSIS(baseAddress)->rCTLW0.r = (EUSCI_A_CMSIS(baseAddress)->rCTLW0.r
1123 & ~(UCCKPH + UCCKPL)) | (clockPhase + clockPolarity);
1125 //Reset the UCSWRST bit to enable the USCI Module
1126 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
1129 //*****************************************************************************
1131 //! \brief Transmits a byte from the SPI Module.
1133 //! This function will place the supplied data into SPI trasmit data register
1134 //! to start transmission.
1136 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1137 //! \param transmitData data to be transmitted from the SPI module
1141 //*****************************************************************************
1142 void EUSCI_A_SPI_transmitData(uint32_t baseAddress, uint8_t transmitData)
1144 EUSCI_A_CMSIS(baseAddress)->rTXBUF.r = transmitData;
1147 //*****************************************************************************
1149 //! \brief Receives a byte that has been sent to the SPI Module.
1151 //! This function reads a byte of data from the SPI receive data Register.
1153 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1155 //! \return Returns the byte received from by the SPI module, cast as an
1158 //*****************************************************************************
1159 uint8_t EUSCI_A_SPI_receiveData(uint32_t baseAddress)
1161 return EUSCI_A_CMSIS(baseAddress)->rRXBUF.r;
1164 //*****************************************************************************
1166 //! \brief Enables individual SPI interrupt sources.
1168 //! Enables the indicated SPI interrupt sources. Only the sources that are
1169 //! enabled can be reflected to the processor interrupt; disabled sources have
1170 //! no effect on the processor. Does not clear interrupt flags.
1172 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1173 //! \param mask is the bit mask of the interrupt sources to be enabled.
1174 //! Mask value is the logical OR of any of the following:
1175 //! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
1176 //! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
1178 //! Modified bits of \b UCAxIFG register and bits of \b UCAxIE register.
1182 //*****************************************************************************
1183 void EUSCI_A_SPI_enableInterrupt(uint32_t baseAddress, uint8_t mask)
1187 & ~(EUSCI_A_SPI_RECEIVE_INTERRUPT
1188 | EUSCI_A_SPI_TRANSMIT_INTERRUPT)));
1190 EUSCI_A_CMSIS(baseAddress)->rIE.r |= mask;
1193 //*****************************************************************************
1195 //! \brief Disables individual SPI interrupt sources.
1197 //! Disables the indicated SPI interrupt sources. Only the sources that are
1198 //! enabled can be reflected to the processor interrupt; disabled sources have
1199 //! no effect on the processor.
1201 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1202 //! \param mask is the bit mask of the interrupt sources to be disabled.
1203 //! Mask value is the logical OR of any of the following:
1204 //! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
1205 //! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
1207 //! Modified bits of \b UCAxIE register.
1211 //*****************************************************************************
1212 void EUSCI_A_SPI_disableInterrupt(uint32_t baseAddress, uint8_t mask)
1216 & ~(EUSCI_A_SPI_RECEIVE_INTERRUPT
1217 | EUSCI_A_SPI_TRANSMIT_INTERRUPT)));
1219 EUSCI_A_CMSIS(baseAddress)->rIE.r &= ~mask;
1222 //*****************************************************************************
1224 //! \brief Gets the current SPI interrupt status.
1226 //! This returns the interrupt status for the SPI module based on which flag is
1229 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1230 //! \param mask is the masked interrupt flag status to be returned.
1231 //! Mask value is the logical OR of any of the following:
1232 //! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
1233 //! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
1235 //! \return Logical OR of any of the following:
1236 //! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
1237 //! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
1238 //! \n indicating the status of the masked interrupts
1240 //*****************************************************************************
1241 uint8_t EUSCI_A_SPI_getInterruptStatus(uint32_t baseAddress, uint8_t mask)
1245 & ~(EUSCI_A_SPI_RECEIVE_INTERRUPT
1246 | EUSCI_A_SPI_TRANSMIT_INTERRUPT)));
1248 return EUSCI_A_CMSIS(baseAddress)->rIFG.r & mask;
1251 //*****************************************************************************
1253 //! \brief Clears the selected SPI interrupt status flag.
1255 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1256 //! \param mask is the masked interrupt flag to be cleared.
1257 //! Mask value is the logical OR of any of the following:
1258 //! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
1259 //! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
1261 //! Modified bits of \b UCAxIFG register.
1265 //*****************************************************************************
1266 void EUSCI_A_SPI_clearInterruptFlag(uint32_t baseAddress, uint8_t mask)
1270 & ~(EUSCI_A_SPI_RECEIVE_INTERRUPT
1271 | EUSCI_A_SPI_TRANSMIT_INTERRUPT)));
1273 EUSCI_A_CMSIS(baseAddress)->rIFG.r &= ~mask;
1276 //*****************************************************************************
1278 //! \brief Enables the SPI block.
1280 //! This will enable operation of the SPI block.
1282 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1284 //! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
1288 //*****************************************************************************
1289 void EUSCI_A_SPI_enable(uint32_t baseAddress)
1291 //Reset the UCSWRST bit to enable the USCI Module
1292 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 0;
1295 //*****************************************************************************
1297 //! \brief Disables the SPI block.
1299 //! This will disable operation of the SPI block.
1301 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1303 //! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
1307 //*****************************************************************************
1308 void EUSCI_A_SPI_disable(uint32_t baseAddress)
1310 //Set the UCSWRST bit to disable the USCI Module
1311 BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rCTLW0.r, UCSWRST_OFS) = 1;
1314 //*****************************************************************************
1316 //! \brief Returns the address of the RX Buffer of the SPI for the DMA module.
1318 //! Returns the address of the SPI RX Buffer. This can be used in conjunction
1319 //! with the DMA to store the received data directly to memory.
1321 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1323 //! \return the address of the RX Buffer
1325 //*****************************************************************************
1326 uint32_t EUSCI_A_SPI_getReceiveBufferAddressForDMA(uint32_t baseAddress)
1328 return baseAddress + OFS_UCA0RXBUF;
1331 //*****************************************************************************
1333 //! \brief Returns the address of the TX Buffer of the SPI for the DMA module.
1335 //! Returns the address of the SPI TX Buffer. This can be used in conjunction
1336 //! with the DMA to obtain transmitted data directly from memory.
1338 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1340 //! \return the address of the TX Buffer
1342 //*****************************************************************************
1343 uint32_t EUSCI_A_SPI_getTransmitBufferAddressForDMA(uint32_t baseAddress)
1345 return baseAddress + OFS_UCA0TXBUF;
1348 //*****************************************************************************
1350 //! \brief Indicates whether or not the SPI bus is busy.
1352 //! This function returns an indication of whether or not the SPI bus is
1353 //! busy.This function checks the status of the bus via UCBBUSY bit
1355 //! \param baseAddress is the base address of the EUSCI_A_SPI module.
1357 //! \return true if busy, false otherwise
1358 //*****************************************************************************
1359 bool EUSCI_A_SPI_isBusy(uint32_t baseAddress)
1361 //Return the bus busy status.
1362 return BITBAND_PERI(EUSCI_A_CMSIS(baseAddress)->rSTATW.r, UCBBUSY_OFS);