📄 cc2420.c
字号:
#include "cc2420.h"void cc2420_init(void) { spi_init(); P4DIR |= BV(CSN) | BV(VREG_EN) | BV(RESET_N); SPI_DISABLE(); /* Unselect radio. */}/* * On the Tmote Sky access to I2C/SPI/UART0 must always be * exclusive. *//* * Initialize SPI bus. */void spi_init(void) { static unsigned char spi_inited = 0; if (spi_inited) return; /* Initalize ports for communication with SPI units. */ U0CTL = CHAR + SYNC + MM + SWRST; /* SW reset,8-bit transfer, SPI master */ U0TCTL = CKPH + SSEL1 + STC; /* Data on Rising Edge, SMCLK, 3-wire. */ U0BR0 = 0x02; /* SPICLK set baud = SMCLK/2 => 250000Hz */ U0BR1 = 0; /* Dont need baud rate control register 2 - clear it */ U0MCTL = 0; /* Dont need modulation control. */ P3SEL |= BV(SCK) | BV(MOSI) | BV(MISO); /* Select Peripheral functionality */ P3DIR |= BV(SCK) | BV(MISO); /* Configure as outputs(SIMO,CLK). */ ME1 |= USPIE0; /* USART SPI module enable */ U0CTL &= ~SWRST; /* SW Reset Cleared, SPI Ready */ IE1 |= (UTXIE0 | URXIE0); /* Enable Transmit and Receive Interrupts */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -