예제 #1
0
void reset(void)	//same function as main()
{
	   char str[]="sunny,sunny day";//inputs are given
	   char w[]="sunny";
	   wmprintf("entered  string is :%s\n",str);//inputs are outputed
	   wmprintf("entered word :%s\n",w);

	int wcount = count(str,w);

    wmprintf("word count : %d\n",wcount);
    if (wcount>0)
    {
    	 gpio_led_on()
    }

	gpio_led = (board_led_2()).gpio; //assigning gpio pin to led
	gpio_pushbutton = board_button_2(); //assigning gpio pin to push button


	configure_gpios();
	wmprintf("Press push button to reset the program.");
	while (1)
		;
	return 0;
}
예제 #2
0
/* This is an entry point for the application.
   All application specific initialization is performed here. */
int main(void)
{
	int ret = 0;

	/* Initializes console on UART0 */
	ret = wmstdio_init(UART0_ID, 0);
	if (ret == -WM_FAIL) {
		wmprintf("Failed to initialize console on uart0\r\n");
		return -1;
	}

	wmprintf(" LED demo application started\r\n");
	wmprintf(" This application demonstrates the"
		 " use of blinking led\r\n");

	gpio_led = (board_led_2()).gpio;

	wmprintf(" LED Pin : %d\r\n", gpio_led);

	configure_gpios();
	while (1) {
		gpio_led_on();
		os_thread_sleep(os_msec_to_ticks(1000));
		gpio_led_off();
		os_thread_sleep(os_msec_to_ticks(1000));
	}
	return 0;
}
예제 #3
0
//Main function, the entry point
int main(void)
{
	int uart_check = 0,i=0,j=0;
	char str[]="sunny,sunny day";//inputs are given
	char w[]="sunny";
	//Checking the status of UART
	uart_check = wmstdio_init(UART0_ID, 0);
	if (uart_check == -WM_FAIL) {
		wmprintf("Failed to initialize console on uart0\r\n");
		return -1;
	}
    	wmprintf("entered  string is :%s\n",str);//inputs are outputed
	wmprintf("entered word :%s\n",w);
	
	int wcount = count(str,w);//ouputting total words

    wmprintf("word count : %d\n",wcount);
    if (wcount>0)
    {
    	 gpio_led_on()
    }

	gpio_led = (board_led_2()).gpio; //assigning gpio pin to led
	gpio_pushbutton = board_button_2(); //assigning gpio pin to push button


	configure_gpios();
	wmprintf("Press push button to reset the program.");
	while (1)
		;
	return 0;
}
예제 #4
0
/* This is an entry point for the application.
   All application specific initialization is performed here. */
int main(void)
{
	int ret = 0;

	/* Initializes console on UART0 */
	ret = wmstdio_init(UART0_ID, 0);
	if (ret == -WM_FAIL) {
		wmprintf("Failed to initialize console on uart0\r\n");
		return -1;
	}

	wmprintf(" GPIO demo application started\r\n");
	wmprintf(" This application demonstrates the"
		 " use of various GPIO driver APIs\r\n");
	wmprintf(" Press button 2 to toggle state of LED\r\n");

	gpio_led = (board_led_2()).gpio;
	gpio_pushbutton = board_button_2();

	wmprintf(" LED Pin : %d\r\n", gpio_led);
	wmprintf(" Pushbutton Pin : %d\r\n", gpio_pushbutton);

	configure_gpios();
	while (1)
		;
	return 0;
}
예제 #5
0
/* This is the main event handler for this project. The application framework
 * calls this function in response to the various events in the system.
 */
int common_event_handler(int event, void *data)
{
    int ret;
    static bool is_cloud_started;
    switch (event) {
    case AF_EVT_WLAN_INIT_DONE:
        ret = psm_cli_init();
        if (ret != WM_SUCCESS)
            wmprintf("Error: psm_cli_init failed\r\n");
        int i = (int) data;

        if (i == APP_NETWORK_NOT_PROVISIONED) {
            wmprintf("\r\nPlease provision the device "
                     "and then reboot it:\r\n\r\n");
            wmprintf("psm-set network ssid <ssid>\r\n");
            wmprintf("psm-set network security <security_type>"
                     "\r\n");
            wmprintf("    where: security_type: 0 if open,"
                     " 3 if wpa, 4 if wpa2\r\n");
            wmprintf("psm-set network passphrase <passphrase>"
                     " [valid only for WPA and WPA2 security]\r\n");
            wmprintf("psm-set network configured 1\r\n");
            wmprintf("pm-reboot\r\n\r\n");
        } else
            app_sta_start();

        break;
    case AF_EVT_NORMAL_CONNECTED:
        set_device_time();
        if (!is_cloud_started) {
            configure_gpios();
            os_thread_sleep(2000);
            ret = os_thread_create(
                      /* thread handle */
                      &app_thread,
                      /* thread name */
                      "evrythng_demo_thread",
                      /* entry function */
                      evrythng_task,
                      /* argument */
                      0,
                      /* stack */
                      &app_stack,
                      /* priority - medium low */
                      OS_PRIO_3);
            is_cloud_started = true;
        }
        break;
    default:
        break;
    }

    return 0;
}
예제 #6
0
/* Enables the device in master or slave full duplex mode.  If you
 * change this code, you must ensure that appropriate changes are made
 * to HardwareSPI::end(). */
void spi_aux_enable_device(spi_dev *dev,
                          bool as_master,
                          SPIFrequency freq,
                          spi_cfg_flag endianness,
                          spi_mode mode) {
    spi_baud_rate baud = determine_baud_rate(dev, freq);
    uint32 cfg_flags = (endianness | SPI_DFF_8_BIT | SPI_SW_SLAVE |
                        (as_master ? SPI_SOFT_SS : 0));

    spi_init(dev);
    configure_gpios(dev, as_master);
    if (as_master) {
        spi_master_enable(dev, baud, mode, cfg_flags);
    } else {
        spi_slave_enable(dev, mode, cfg_flags);
    }
}
예제 #7
0
/* This is an entry point for the application.
   All application specific initialization is performed here. */
int main(void)
{
    int ret = 0;
    TaskHandle_t blinkLEDHandle = NULL;
    int priority;

    /* Initializes console on UART0 */
    ret = wmstdio_init(UART0_ID, 0);
    if (ret == -WM_FAIL)
    {
        wmprintf("Failed to initialize console on uart0\r\n");
        return -1;
    }

    wmprintf(" LED demo application started\r\n");
    wmprintf(" This application demonstrates the"
                  " use of blinking led\r\n");

    gpio_led = (board_led_2()).gpio;

    wmprintf(" LED Pin : %d\r\n", gpio_led);

    configure_gpios();

    xTaskCreate(prvBlinkLedTask, "Blink led", ( uint16_t ) BLINK_LED_STACK_SIZE, NULL, ( ( UBaseType_t ) BLINK_LED_TASK_PRIORITY ) | portPRIVILEGE_BIT, &blinkLEDHandle);
    // dump blink led task related information
    if (NULL != blinkLEDHandle)
    {
        priority = uxTaskPriorityGet(blinkLEDHandle);
        wmprintf("blink led priority is %d\r\n", priority);
        wmprintf("blink led task name:%s\r\n", pcTaskGetTaskName(blinkLEDHandle));
    }
    wmprintf("run blink led task for 30 seconds\r\n");
    vTaskDelay(30000);
    wmprintf("delete blink led task\r\n");
    if (NULL != blinkLEDHandle)
    {
        vTaskDelete(blinkLEDHandle);
        blinkLEDHandle = NULL;
    }
    while (1)
    {
        vTaskDelay(1000);
    }
    return 0;
}
예제 #8
0
static void enable_device(can_dev *dev, CANFrequency freq, uint32 options, uint32 ier_options, uint32 mode) {
    /* Using TBS1=4, TBS2=3,
       we get nominal bit timing
       = Tpclk * (BRP+1) * (1+4+3)
       = Tpclk * (BRP+1) * 6
       If the clk is running at 36MHz, then we want
       BRP+1 = 6 to get a 1MHz baud rate.
    */
    
    uint32 target = 1;
    switch (freq) {
        case CAN_1MHZ:
            target = 1000000;
            break;
        case CAN_500KHZ:
            target = 500000;
            break;
        case CAN_250KHZ:
            target = 250000;
            break;
        case CAN_125KHZ:
            target = 125000;
            break;
        default:
            ASSERT(0);
    }

    uint8 SJW = 4 - 1;
    uint8 TS2 = 3 - 1;
    uint8 TS1 = 4 - 1;
    uint16 BRP = ((STM32_PCLK1 / 6) / target) - 1;
    uint32 timing = BRP;

    timing |= TS1 << 16;
    timing |= TS2 << 20;
    timing |= SJW << 24;

    can_init(dev);
    configure_gpios(dev);
    can_reconfigure(dev, options, ier_options, mode | timing);

}