This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

如何使用CC2530的CSMA机制发送数据?

Other Parts Discussed in Thread: CC2530, Z-STACK, SIMPLICITI

请问怎样使用csp实现CSMA?  在zigbee协议栈中,是通过下面的代码去实现,但是我移植出来后使用不了?

还有里面 的mac定时器2的  事件是怎么理解的  RFST = WEVENT1;

mac定时器2是需要怎样的初始化以及中断函数里面该处理什么?

是需要mac定时器2中的中断函数里面做什么设置之类的么?

还有里面的随机数值产生器需要进行怎样初始化以及怎样使用?

是否有csma的相关demo可以学习下?

void macCspTxPrepCsmaUnslotted(void)
{
cspPrepForTxProgram();

/*----------------------------------------------------------------------
* Load CSP program : Unslotted CSMA transmit
*/

/*
* Wait for X number of backoffs, then wait for intra-backoff count
* to reach value set for WEVENT1.
*/
RFST = WAITX;
RFST = WEVENT1;

/* wait for one backoff to guarantee receiver has been on at least that long */
RFST = WAITW(1);
RFST = WEVENT1;

/* sample CCA, if it fails exit from here, CSPZ indicates result */
RFST = SKIP(1, C_CCA_IS_VALID);
RFST = SSTOP;

/* CSMA has passed so transmit (actual frame starts one backoff from when strobe is sent) */
RFST = STXON;

/*
* Wait for the start of frame delimiter of the transmitted frame. If SFD happens to
* already be active when STXON is strobed, it gets forced low. How long this takes
* though, is not certain. For bulletproof operation, the first step is to wait
* until SFD is inactive (which should be very fast if even necessary), and then wait
* for it to go active.
*/
RFST = WHILE(C_SFD_IS_ACTIVE);
RFST = WHILE(C_SFD_IS_INACTIVE);

/*
* Record the timestamp. The INT instruction causes an interrupt to fire.
* The ISR for this interrupt records the timestamp (which was just captured
* when SFD went high).
*/
RFST = INT;

/*
* Wait for SFD to go inactive which is the end of transmit. Decrement CSPZ to indicate
* the transmit was successful.
*/
RFST = WHILE(C_SFD_IS_ACTIVE);
RFST = DECZ;

/*
* CC2530 requires SSTOP to generate CSP_STOP interrupt.
*/
RFST = SSTOP;