示例#1
0
/***********************************************************************************
* @fn      halRfTransmit
*
* @brief   Transmit frame with Clear Channel Assessment.
*
* @param   none
*
* @return  uint8 - HAL_RF_SUCCESS or HAL_RF_FAILED
*/
uint8 halRfTransmit(void)
{
    uint16 timeout = 2500; // 2500 x 20us = 50ms
    uint8 status=0;

    // DEBUG_MSG_FUNC_START;

    // Wait for RSSI to become valid
    while(!CC2520_RSSI_VALID_PIN);

    // Reuse GPIO2 for TX_FRM_DONE exception
    HAL_INT_OFF();
    CC2520_CFG_GPIO_OUT(2, 1 + CC2520_EXC_TX_FRM_DONE);
    HAL_INT_ON();

    // Wait for the transmission to begin before exiting (makes sure that this function cannot be called
    // a second time, and thereby cancelling the first transmission.
    while(--timeout > 0) {
        HAL_INT_OFF();
        CC2520_INS_STROBE(CC2520_INS_STXONCCA);
        HAL_INT_ON();
        if (CC2520_SAMPLED_CCA_PIN) break;
#if 0 // POOH
        halMcuWaitUs(20);
#else
        Delay(20);
#endif
    }
    if (timeout == 0) {
        DEBUG_MSG_FUNC_ERROR;
        status = HAL_RF_FAILED;
        CC2520_INS_STROBE(CC2520_INS_SFLUSHTX);
    }
    else {
        status = HAL_RF_SUCCESS;
        // Wait for TX_FRM_DONE exception
        while(!CC2520_TX_FRM_DONE_PIN);
        HAL_INT_OFF();
        CC2520_CLEAR_EXC(CC2520_EXC_TX_FRM_DONE);
        HAL_INT_ON();
    }

    // Reconfigure GPIO2
    HAL_INT_OFF();
    CC2520_CFG_GPIO_OUT(2,     CC2520_GPIO_RSSI_VALID);
    HAL_INT_ON();
    return status;
}
示例#2
0
/***********************************************************************************
* @fn      halRfWaitTransceiverReady
*
* @brief   Wait until the transceiver is ready (SFD low).
*
* @param   none
*
* @return  none
*/
void halRfWaitTransceiverReady(void)
{
#ifdef INCLUDE_PA
    // GPIO3 is not conncted to combo board; use SFD at GPIO2 instead
    HAL_INT_OFF();
    // GPIO2 = SFD
    CC2520_CFG_GPIO_OUT(2,CC2520_GPIO_SFD);
    while (CC2520_GPIO2_IPIN);
    // GPIO2 = default (RSSI_VALID)
    CC2520_CFG_GPIO_OUT(2,CC2520_GPIO_RSSI_VALID);
    HAL_INT_ON();
#else
    while (CC2520_GPIO3_IPIN);
#endif
}
示例#3
0
/***********************************************************************************
 * @fn      halIntOff
 *
 * @brief   Turns global interrupts off.
 *
 * @param   none
 *
 * @return  none
 */
void halIntOff(void) {
	HAL_INT_OFF();
}