cc2420.c

来自「zigbee 协议堆栈 stack(简化协议)」· C语言 代码 · 共 44 行

C
44
字号
#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 + =
减小字号Ctrl + -
显示快捷键?