📄 hal_spi.c
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON HARDWARE ABSTRACTION LIBRARY FOR THE CC2420 *
* *** + + *** Idle looping *
* *** +++ *** *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* The Chipcon Hardware Abstraction Library is a collection of functions, macros and constants, which *
* can be used to ease access to the hardware on the CC2420 and the target microcontroller. *
* *
* This file contains a function which initialises the SPI interface on UART1.
*******************************************************************************************************
* Compiler: MPS430-GCC or IAR C/C++ Compiler for MSP430
* Target platform: MSP430FET CC2420 + any ATMEGA MCU *
*******************************************************************************************************
* Revision history: *
*
*
*
*******************************************************************************************************/
#include <include.h>
//-------------------------------------------------------------------------------------------------------
// void halSpiInit(void)
//
// DESCRIPTION:
// Initalises the MSP430 Port 5/UART1 for SPI use.
//
//-------------------------------------------------------------------------------------------------------
void halSpiInit(void) {
U1CTL = CHAR + SYNC + MM + SWRST; // SW reset, 8-bit transfer, SPI master
U1TCTL = CKPH + SSEL1 + STC; // Data on Rising Edge, SMCLK, 3-wire
U1BR0 = 0x02; // SPICLK set baud
U1BR1 = 0; // Dont need baud rate control register 2 - clear it
U1MCTL = 0; // Dont need modulation control
P5SEL= BIT1+BIT2+BIT3; // Select Peripheral functionality (SPI)
P5DIR= BIT1+BIT3+BIT4; // Configure as outputs(SIMO,CLK,CSn)
ME2 |= USPIE1; // Module enable
U1CTL &= ~SWRST; // Remove RESET
} // SpiInit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -