Example #1
0
void amb8420Init(void)
{
    RPRINTF("amb8420Init...\n");

    amb8420InitSerial();

    pinAsOutput(AMB8420_RESET_PORT, AMB8420_RESET_PIN);
    pinAsOutput(AMB8420_CONFIG_PORT, AMB8420_CONFIG_PIN);
    pinAsOutput(AMB8420_SLEEP_PORT, AMB8420_SLEEP_PIN);
    pinAsOutput(AMB8420_TRX_DISABLE_PORT, AMB8420_TRX_DISABLE_PIN);
    // pinAsOutput(AMB8420_DATA_REQUEST_PORT, AMB8420_DATA_REQUEST_PIN);
    pinAsInput(AMB8420_RTS_PORT, AMB8420_RTS_PIN);
    // pinAsInput(AMB8420_DATA_INDICATE_PORT, AMB8420_DATA_INDICATE_PIN);

    pinSet(AMB8420_CONFIG_PORT, AMB8420_CONFIG_PIN);
    // pinClear(AMB8420_DATA_REQUEST_PORT, AMB8420_DATA_REQUEST_PIN);

    // in case interrupts are used (for non-command mode):
    //pinIntRising(AMB8420_DATA_INDICATE_PORT, AMB8420_DATA_INDICATE_PIN);
    //pinEnableInt(AMB8420_DATA_INDICATE_PORT, AMB8420_DATA_INDICATE_PIN);

    initResult = amb8420Reset();

    // make sure low power mode is enabled
    pinSet(AMB8420_TRX_DISABLE_PORT, AMB8420_TRX_DISABLE_PIN);
    pinSet(AMB8420_SLEEP_PORT, AMB8420_SLEEP_PIN);

    alarmInit(&radioResetTimer, onRadioReset, NULL);
    alarmSchedule(&radioResetTimer, RADIO_RESET_INTERVAL);

    RPRINTF("..done\n");
}
Example #2
0
static void serialInitPins1(void) {
    // serial 1
    pinAsOutput(UTXD1_PORT, UTXD1_PIN);
    pinAsInput(URXD1_PORT, URXD1_PIN);
    pinClear(UTXD1_PORT, UTXD1_PIN);
    pinAsFunction(UTXD1_PORT, UTXD1_PIN);
    pinAsFunction(URXD1_PORT, URXD1_PIN);
}
Example #3
0
uint_t serialInit(uint8_t id, uint32_t speed, uint8_t conf)
{
    if (conf != 0) return -ENOSYS;
    // support only one baudrate (XXX: panic on error?)
    if (speed != SOFT_SERIAL_BAUDRATE) return -ENOSYS;

    if (id == 0) {
        pinAsData(UART0_TX_PORT, UART0_TX_PIN);
        pinAsOutput(UART0_TX_PORT, UART0_TX_PIN);

        pinAsData(UART0_RX_PORT, UART0_RX_PIN);
        pinAsInput(UART0_RX_PORT, UART0_RX_PIN);

#if UART0_HW_TX_PORT != UART0_TX_PORT
        // -- also setup HW serial ports in the same mode
        pinAsData(UART0_HW_TX_PORT, UART0_HW_TX_PIN);
        pinAsInput(UART0_HW_TX_PORT, UART0_HW_TX_PIN);
//        pinAsOutput(UART0_HW_TX_PORT, UART0_HW_TX_PIN);

        pinAsData(UART0_HW_RX_PORT, UART0_HW_RX_PIN);
        pinAsInput(UART0_HW_RX_PORT, UART0_HW_RX_PIN);
#endif

#if USE_SW_SERIAL_INTERRUPTS
        // PRINTF("serial int init\n");
        pinEnableInt(UART0_RX_PORT, UART0_RX_PIN);
        pinIntFalling(UART0_RX_PORT, UART0_RX_PIN);
        pinClearIntFlag(UART0_RX_PORT, UART0_RX_PIN);
#endif
    }
    else {
        pinAsData(UART1_TX_PORT, UART1_TX_PIN);
        pinAsOutput(UART1_TX_PORT, UART1_TX_PIN);

        pinAsData(UART1_RX_PORT, UART1_RX_PIN);
        pinAsInput(UART1_RX_PORT, UART1_RX_PIN);
    }

    // Configure Timer_B
    TBCTL = TBCLR;
    TBCTL = TBSSEL_2 + MC_2; // clock = SMCLK

    // Initialize UART
    if (id == 0) {
        pinSet(UART0_TX_PORT, UART0_TX_PIN);
//        pinSet(UART0_HW_TX_PORT, UART0_HW_TX_PIN);
    } else {
        pinSet(UART1_TX_PORT, UART1_TX_PIN);
    }

    TBCCTL0 = 0;
    TBCCTL1 = 0;
    TBCCTL2 = 0;
#ifdef TBCCTL3_
    TBCCTL3 = 0;
    TBCCTL4 = 0;
    TBCCTL5 = 0;
    TBCCTL6 = 0;
#endif

//    TACTL = TACLR;

#ifndef USE_SW_SERIAL_INTERRUPTS
    TBCCR2 = TBR + 100;
    TBCCTL2 = CCIE;
#endif

    return 0;
}