Esempio n. 1
0
static void prvSetupHardware( void )
{
extern void FPU_enableModule( void );
	
	/* The clocks are not configured here, but inside main_full() and
	main_blinky() as the full demo uses a fast clock and the blinky demo uses
	a slow clock. */

	/* Stop the watchdog timer. */
	MAP_WDT_A_holdTimer();
	
	/* Ensure the FPU is enabled. */
	FPU_enableModule();

	/* Selecting P1.2 and P1.3 in UART mode and P1.0 as output (LED) */
	MAP_GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P1, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION );
	MAP_GPIO_setOutputLowOnPin( GPIO_PORT_P1, GPIO_PIN0 );
	MAP_GPIO_setAsOutputPin( GPIO_PORT_P1, GPIO_PIN0 );

	/* Enable S2 and LED2 */
	MAP_GPIO_setOutputLowOnPin( GPIO_PORT_P2, GPIO_PIN0 );
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0);
	MAP_GPIO_setOutputLowOnPin( GPIO_PORT_P2, GPIO_PIN1 );
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN1);
	MAP_GPIO_setOutputLowOnPin( GPIO_PORT_P2, GPIO_PIN2 );
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN2);

	MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN4);
	MAP_GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN4, GPIO_HIGH_TO_LOW_TRANSITION);
	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN4);
	MAP_GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN4);
	MAP_Interrupt_enableInterrupt(INT_PORT1);

}
void SW1_IRQHandler(void){
	uint32_t status;
	status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P5);
	_delay_cycles(3000000);
	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P5, status);

	Semaphore_post(Button_Semaphore);
}
/*
 *  ======== WiFiCC3100_open ========
 */
WiFi_Handle WiFiCC3100_open(WiFi_Handle handle, unsigned int spiIndex,
	WiFi_evntCallback evntCallback, WiFi_Params *params)
{
    unsigned int              key;
    WiFiCC3100_Object        *object = handle->object;
    WiFiCC3100_HWAttrs const *hwAttrs = handle->hwAttrs;
    union {
#if !defined(MSP430WARE)
        Hwi_Params            hwiParams;
#endif
        Semaphore_Params      semParams;
    } paramsUnion;

    key = Hwi_disable();
    if (object->isOpen) {
        Hwi_restore(key);
        Log_warning0("WiFi Hwi already in use.");
        return (NULL);
    }
    object->isOpen = true;
    Hwi_restore(key);

    /* Construct semaphores to block read/write transactions. */
    Semaphore_Params_init(&(paramsUnion.semParams));
    paramsUnion.semParams.mode = Semaphore_Mode_BINARY;
    paramsUnion.semParams.instance->name = "WiFi.writeSemaphore";
    Semaphore_construct(&(object->writeSemaphore), 0, &(paramsUnion.semParams));

    paramsUnion.semParams.instance->name = "WiFi.readSemaphore";
    Semaphore_construct(&(object->readSemaphore), 0, &(paramsUnion.semParams));

#if !defined(MSP430WARE)
    Hwi_Params_init(&(paramsUnion.hwiParams));
    paramsUnion.hwiParams.arg = (UArg) handle;
    paramsUnion.hwiParams.enableInt = false;

    /* Hwi_construct cannot fail, use NULL instead of an Error Block */
    Hwi_construct(&(object->wifiHwi), hwAttrs->irqIntNum,
	    WiFiCC3100_hostIntHandler, &(paramsUnion.hwiParams), NULL);
#endif

#if defined(MSP430WARE) || defined(MSP432WARE)
    MAP_GPIO_clearInterruptFlag(hwAttrs->irqPort, hwAttrs->irqPin);
    MAP_GPIO_enableInterrupt(hwAttrs->irqPort, hwAttrs->irqPin);
#else
    GPIOIntClear(hwAttrs->irqPort, hwAttrs->irqPin);
    GPIOIntEnable(hwAttrs->irqPort, hwAttrs->irqPin);
#endif

    /* Store SPI interface parameters */
    object->spiIndex = spiIndex;
    object->bitRate = params->bitRate;

    return (handle);
}
Esempio n. 4
0
/* GPIO ISR */
void gpio_isr(void)
{
    uint32_t status;

    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P6);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P6, status);

    msprf24_get_irq_reason();

    //Turn on RED LED
    MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN0);

}
/* GPIO ISR */
void PORT1_IRQHandler(void)
{
    uint32_t status;

    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, status);

    /* Toggling the output on the LED */
    if(status & GPIO_PIN4)
    {
        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN1);
        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P5, GPIO_PIN0);
    }

}
Esempio n. 6
0
//-----------------------------------------------------------------------
// GPIO ISR
void gpio_isr(void)
{
    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P6);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P6, status);

    msprf24_get_irq_reason();  // this updates rf_irq
	if (rf_irq & RF24_IRQ_TX)
	{
		//indicating there was a valid packet received
		status = 1;
	}
	if (rf_irq & RF24_IRQ_TXFAILED)
	{
		//indicating there was an invalid packet received
		status = 0;
	}
	msprf24_irq_clear(RF24_IRQ_MASK);  // Clear any/all of them
}
/*
 *  ======== WiFiCC3100_hostIntHandler ========
 *  SimpleLink Host Driver interrupt handler.  Calls previously registered
 *  functions to handle network processor.
 */
void WiFiCC3100_hostIntHandler(UArg arg)
{
    WiFiCC3100_Object        *object = wifiHandle->object;
    WiFiCC3100_HWAttrs const *hwAttrs = wifiHandle->hwAttrs;

    Assert_isTrue(object->wifiIntFxn != NULL, NULL);

    Log_print0(Diags_USER2, "Entering WiFi Hwi handler.");

#if defined(MSP430WARE) || defined(MSP432WARE)
    MAP_GPIO_clearInterruptFlag(hwAttrs->irqPort, hwAttrs->irqPin);
#else
    GPIOIntClear(hwAttrs->irqPort, hwAttrs->irqPin);
#endif

    (*object->wifiIntFxn)();

    Log_print0(Diags_USER2, "Exiting WiFi Hwi handler.");
}
Esempio n. 8
0
//-----------------------------------------------------------------------
int RF_Init(void)
{
	int err = 0;

	//Setting RGB LED as output
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
	GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);
	GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

	//Set P6.1 to be the pin interupt
	MAP_GPIO_setAsInputPin(GPIO_PORT_P6, GPIO_PIN1);
	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P6, GPIO_PIN1);
	MAP_GPIO_enableInterrupt(GPIO_PORT_P6, GPIO_PIN1);

	//Enable the gpio interupt
	MAP_Interrupt_enableInterrupt(INT_PORT6);
	MAP_Interrupt_enableMaster();

    /* Initial values for nRF24L01+ library config variables */
    rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit
    rf_addr_width      = (uint8_t)PACKET_SIZE;
    rf_speed_power     = RF24_SPEED_MIN | RF24_POWER_MAX;
    rf_channel     	   = 120;

    msprf24_init();  // All RX pipes closed by default
    msprf24_set_pipe_packetsize(0, (uint8_t)PACKET_SIZE);
    msprf24_open_pipe(0, 1);  // Open pipe#0 with Enhanced ShockBurst enabled for receiving Auto-ACKs

    // Transmit to 'rad01' (0x72 0x61 0x64 0x30 0x31)
    msprf24_standby();
    user = msprf24_current_state();
    memcpy(addr, "\xDE\xAD\xBE\xEF\x01", 5);
//    addr[0] = 0xDE; addr[1] = 0xAD; addr[2] = 0xBE; addr[3] = 0xEF; addr[4] = 0x00;
    w_tx_addr(addr);
    w_rx_addr(0, addr);  // Pipe 0 receives auto-ack's, autoacks are sent back to the TX addr so the PTX node
                     // needs to listen to the TX addr on pipe#0 to receive them.
    msprf24_activate_rx();

	return err;
}
Esempio n. 9
0
//------------------------------------------------------------------------------
int InitFunction(void)
{
	int err = NONE;

	MAP_WDT_A_holdTimer();

	/* Configuring P6.7 as an input. P1.0 as output and enabling interrupts */
//	MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);
	//Setting RGB LED as output
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);

	//Set P6.1 to be the pin interupt
	MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P6, GPIO_PIN1);
	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P6, GPIO_PIN1);
	MAP_GPIO_enableInterrupt(GPIO_PORT_P6, GPIO_PIN1);
	MAP_Interrupt_enableInterrupt(INT_PORT6);

	MAP_Interrupt_enableMaster();

	return err;
}
Esempio n. 10
0
//------------------------------------------------------------------------------
// GPIO ISR
void gpio_isr(void)
{
    uint32_t status;

    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P6);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P6, status);

    msprf24_get_irq_reason();  // this updates rf_irq
	if (rf_irq & RF24_IRQ_TX)
	{
		status = 1;
		GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);
		GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN1);
	}
	if (rf_irq & RF24_IRQ_TXFAILED)
	{
		status = 0;
		GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);
		GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN0);
	}
	msprf24_irq_clear(RF24_IRQ_MASK);  // Clear any/all of them
}