Ejemplo n.º 1
0
void ssd1306_init(void)
{
	oled_spi_dev.port = 1;
	oled_spi_dev.config.mode = HAL_SPI_MODE_MASTER;
	oled_spi_dev.config.freq = 6000000;
	hal_spi_init(&oled_spi_dev);

	//config reset and ds pin
	gpio_oled_reset.port = 8; //PA8
	gpio_oled_reset.config = OUTPUT_PUSH_PULL;
	hal_gpio_init(&gpio_oled_reset);
	hal_gpio_output_high(&gpio_oled_reset);

	gpio_oled_cs.port = 22; //PA22
	gpio_oled_cs.config = OUTPUT_PUSH_PULL;
	hal_gpio_init(&gpio_oled_cs);
	hal_gpio_output_high(&gpio_oled_cs);
	aos_msleep(1);
	hal_gpio_output_low(&gpio_oled_cs);

	gpio_oled_ds.port = 20; //PA20
	gpio_oled_ds.config = OUTPUT_PUSH_PULL;
	hal_gpio_init(&gpio_oled_ds);
	hal_gpio_output_high(&gpio_oled_ds);

	aos_msleep(1);
	hal_gpio_output_low(&gpio_oled_reset);
	aos_msleep(1);
	hal_gpio_output_high(&gpio_oled_reset);

	//config oled
	ssd1306_write(SSD1306_DISPLAYOFF, SSD1306_CMD);
	ssd1306_write(SSD1306_SETDISPLAYCLOCKDIV, SSD1306_CMD);
	ssd1306_write(80, SSD1306_CMD);
	ssd1306_write(SSD1306_SETMULTIPLEX, SSD1306_CMD);
	ssd1306_write(0x3F, SSD1306_CMD);
	ssd1306_write(SSD1306_SETDISPLAYOFFSET, SSD1306_CMD);
	ssd1306_write(0x00, SSD1306_CMD);
	ssd1306_write(SSD1306_SETSTARTLINE, SSD1306_CMD);
	ssd1306_write(SSD1306_ENABLE_CHARGE_PUMP, SSD1306_CMD);
	ssd1306_write(0x14, SSD1306_CMD);
	ssd1306_write(SSD1306_MEMORYMODE, SSD1306_CMD);
	ssd1306_write(0x02, SSD1306_CMD);
	ssd1306_write(0xA1, SSD1306_CMD);
	ssd1306_write(SSD1306_COMSCANINC, SSD1306_CMD);
	ssd1306_write(SSD1306_SETCOMPINS, SSD1306_CMD);
	ssd1306_write(0X12, SSD1306_CMD);
	ssd1306_write(SSD1306_SETCONTRAST, SSD1306_CMD);
	ssd1306_write(0x1F, SSD1306_CMD); //set brightness
	ssd1306_write(SSD1306_SETPRECHARGE, SSD1306_CMD);
	ssd1306_write(0xF1, SSD1306_CMD);
	ssd1306_write(SSD1306_SETVCOMDETECT, SSD1306_CMD);
	ssd1306_write(0x30, SSD1306_CMD);
	ssd1306_write(SSD1306_DISPLAYALLON_RESUME, SSD1306_CMD);
	ssd1306_write(SSD1306_NORMALDISPLAY, SSD1306_CMD);
	ssd1306_write(SSD1306_DISPLAYON, SSD1306_CMD);

	return 0;
}
Ejemplo n.º 2
0
static void do_auto_active()
{
    alink_activate(NULL);
    LOG("--------auto active done------");
    aos_msleep(ACTIVE_DELAY);
    clear_kv_and_reboot();
}
Ejemplo n.º 3
0
/*
 * Subscribe the topic: IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
 * Publish the topic: IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
 */
static void mqtt_publish(void *pclient) {

    int rc = -1;

    if(is_subscribed == 0) {
        /* Subscribe the specific topic */
        rc = IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
        if (rc<0) {
            // IOT_MQTT_Destroy(&pclient);
             LOG("IOT_MQTT_Subscribe() failed, rc = %d", rc);
        }
        is_subscribed = 1;
        aos_schedule_call(ota_init, gpclient);
    }
    else{
        /* Initialize topic information */
        memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t));

        topic_msg.qos = IOTX_MQTT_QOS1;
        topic_msg.retain = 0;
        topic_msg.dup = 0;

        /* Generate topic message */
        int msg_len = snprintf(msg_pub, sizeof(msg_pub), "{\"attr_name\":\"temperature\", \"attr_value\":\"%d\"}", cnt);
        if (msg_len < 0) {
            LOG("Error occur! Exit program");
        }

        topic_msg.payload = (void *)msg_pub;
        topic_msg.payload_len = msg_len;

        rc = IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
        if (rc < 0) {
            LOG("error occur when publish");
        }
#ifdef MQTT_ID2_CRYPTO
        LOG("packet-id=%u, publish topic msg='0x%02x%02x%02x%02x'...",
                (uint32_t)rc,
                msg_pub[0], msg_pub[1], msg_pub[2], msg_pub[3]);
#else
        LOG("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub);
#endif
    }
    cnt++;
    if(cnt < 200) {
        aos_post_delayed_action(3000, mqtt_publish, pclient);
    } else {

        IOT_MQTT_Unsubscribe(pclient, TOPIC_DATA);

        aos_msleep(200);

        IOT_MQTT_Destroy(&pclient);

        release_buff();

        is_subscribed = 0;
        cnt = 0;
    }
}
Ejemplo n.º 4
0
Archivo: nano.c Proyecto: wosayttn/aos
int application_start(int argc, char *argv[])
{
    do
    {
        app_delayed_action(NULL);
        aos_msleep(1000);
    }while(1);
}
Ejemplo n.º 5
0
int pal_pcm_recode_with_cb(get_recode_stream_fn fn)
{
	int ret = 0;
	int snd_read_num = 0;


    LOGI("palapp","pal_pcm_recode_with_cb\n");
	ret = snd_pcm_open(&pal_pcm_cfg, SOUND_CARD_ID_IN, PCM_IN);
	if (ret != 0) {
		LOGE("palapp","pcm open error\n");
		ret = -1;
	}
#ifdef SAVE_TO_SD
    char file_name[64];
	sprintf(file_name,"0:/%d.wav",aos_now());
	int f_sta = f_open(&pcm_fp, file_name, FA_CREATE_NEW | FA_WRITE | FA_READ);
	if(f_sta != FR_OK) {
		LOG("!!!!!fail to open fat!!!!!\n");
		return -1;
	}
#endif	

	int recd_count = READ_CNT;
	unsigned int write_l = 0;
	LOG("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
	LOG("~~~~~~~~~~~~~~~~~~~~~~~~Please say some thing to me~~~~~~~~~~~~~~~~~~~~~~~~~~~");
	draw_text(0,0,1,"Please say some thing to me");
	aos_msleep(500);
	while(recd_count --) {

		snd_read_num = snd_pcm_read(&pal_pcm_cfg, SOUND_CARD_ID_IN, pcm_data_buf, PCM_BUF_SIZE);
		if(snd_read_num == -1) {
			LOG("!!!!!!!!pcm read error!!!!!!!!\n");
			return -1;
		}
#ifdef SAVE_TO_SD

        
#endif
        
		int size=PCM_BUF_SIZE/PCM_BUF_CNT;
		for(int i=0;i<PCM_BUF_CNT;i++){
		    fn(pcm_data_buf+i*size,size);
			//aos_msleep(5);
		}
	}
	draw_text(0,0,1,"In the processing...");
	snd_pcm_close(SOUND_CARD_ID_IN, PCM_IN);
	LOG("recoder end!\n");
#ifdef SAVE_TO_SD
  	f_close(&pcm_fp);
#endif
	return ret;
} 
Ejemplo n.º 6
0
/**
 * @brief   启动一次Wi-Fi的空中扫描(Scan)
 *
 * @param[in] cb @n pass ssid info(scan result) to this callback one by one
 * @return 0 for wifi scan is done, otherwise return -1
 * @see None.
 * @note
 *      This API should NOT exit before the invoking for cb is finished.
 *      This rule is something like the following :
 *      HAL_Wifi_Scan() is invoked...
 *      ...
 *      for (ap = first_ap; ap <= last_ap; ap = next_ap){
 *        cb(ap)
 *      }
 *      ...
 *      HAL_Wifi_Scan() exit...
 */
int HAL_Wifi_Scan(awss_wifi_scan_result_cb_t cb)
{
    netmgr_register_wifi_scan_result_callback((netmgr_wifi_scan_result_cb_t)cb);
    hal_wifi_start_scan_adv(NULL);

    while (netmgr_get_scan_cb_finished() != true) { // block
        aos_msleep(500);
    }

    return 0;
}
Ejemplo n.º 7
0
/*
 * Subscribe the topic: IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
 * Publish the topic: IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
 */
static void mqtt_work(void *parms)
{

    int rc = -1;

    if (is_subscribed == 0) {
        /* Subscribe the specific topic */
        rc = mqtt_subscribe(TOPIC_GET, mqtt_sub_callback, NULL);
        if (rc < 0) {
            // IOT_MQTT_Destroy(&pclient);
            LOG("IOT_MQTT_Subscribe() failed, rc = %d", rc);
        }
        is_subscribed = 1;
        aos_schedule_call(ota_init, NULL);
    }
#ifndef MQTT_PRESS_TEST
    else {
        /* Generate topic message */
        int msg_len = snprintf(msg_pub, sizeof(msg_pub), "{\"attr_name\":\"temperature\", \"attr_value\":\"%d\"}", cnt);
        if (msg_len < 0) {
            LOG("Error occur! Exit program");
        }
        rc = mqtt_publish(TOPIC_UPDATE, IOTX_MQTT_QOS1, msg_pub, msg_len);
        if (rc < 0) {
            LOG("error occur when publish");
        }

        LOG("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub);
    }
    cnt++;
    if (cnt < 200) {
        aos_post_delayed_action(3000, mqtt_work, NULL);
    } else {
        aos_cancel_delayed_action(3000, mqtt_work, NULL);
        mqtt_unsubscribe(TOPIC_GET);
        aos_msleep(200);
        mqtt_deinit_instance();
        is_subscribed = 0;
        cnt = 0;
    }
#endif
}
Ejemplo n.º 8
0
/**
 * @brief   要求Wi-Fi网卡连接指定热点(Access Point)的函数
 *
 * @param[in] connection_timeout_ms @n AP connection timeout in ms or HAL_WAIT_INFINITE
 * @param[in] ssid @n AP ssid
 * @param[in] passwd @n AP passwd
 * @param[in] auth @n optional(AWSS_AUTH_TYPE_INVALID), AP auth info
 * @param[in] encry @n optional(AWSS_ENC_TYPE_INVALID), AP encry info
 * @param[in] bssid @n optional(NULL or zero mac address), AP bssid info
 * @param[in] channel @n optional, AP channel info
 * @return
   @verbatim
     = 0: connect AP & DHCP success
     = -1: connect AP or DHCP fail/timeout
   @endverbatim
 * @see None.
 * @note
 *      If the STA connects the old AP, HAL should disconnect from the old AP firstly.
 */
int HAL_Awss_Connect_Ap(
    _IN_ uint32_t connection_timeout_ms,
    _IN_ char ssid[HAL_MAX_SSID_LEN],
    _IN_ char passwd[HAL_MAX_PASSWD_LEN],
    _IN_OPT_ enum AWSS_AUTH_TYPE auth,
    _IN_OPT_ enum AWSS_ENC_TYPE encry,
    _IN_OPT_ uint8_t bssid[ETH_ALEN],
    _IN_OPT_ uint8_t channel)
{
    int ret, ms_cnt = 0;
    netmgr_ap_config_t config;
    if (ssid != NULL) {
        strncpy(config.ssid, ssid, sizeof(config.ssid) - 1);
    }
    if (passwd != NULL) {
        strncpy(config.pwd, passwd, sizeof(config.pwd) - 1);
    }
    if (bssid != NULL) {
        memcpy(config.bssid, bssid, ETH_ALEN);
    }
    ret = netmgr_set_ap_config(&config);
#ifndef ESP8266_CONFIG
    printf("------------------------suspend station\n");
    hal_wifi_suspend_station(NULL);
#endif
    LOGI("aos_awss", "Will reconnect wifi: %s %s", ssid, passwd);
    netmgr_reconnect_wifi();

    while (ms_cnt < connection_timeout_ms) {
        if (netmgr_get_ip_state() == false) {
            LOGD("[waitConnAP]", "waiting for connecting AP");
            aos_msleep(500);
            ms_cnt += 500;
        } else {
            LOGI("[waitConnAP]", "AP connected");
            return 0;
        }
    }

    return -1;
}
Ejemplo n.º 9
0
static void at_worker(void *arg)
{
    int        offset                  = 0;
    int        ret                     = 0;
    int        at_task_empty           = 0;
    int        at_task_reponse_begin   = 0;
    int        memcpy_size             = 0;
    int        rsp_prefix_len          = 0;
    int        rsp_success_postfix_len = 0;
    int        rsp_fail_postfix_len    = 0;
    char       c;
    at_task_t *tsk;
    char *     buf                 = NULL;
    char *     rsp_prefix          = NULL;
    char *     rsp_success_postfix = NULL;
    char *     rsp_fail_postfix    = NULL;
    oob_t *    oob                 = NULL;

    LOGD(MODULE_NAME, "at_work started.");

    buf = aos_malloc(RECV_BUFFER_SIZE);
    if (NULL == buf) {
        LOGE(MODULE_NAME, "AT worker fail to malloc ,task exist \r\n");
        aos_task_exit(0);
        return;
    }

    memset(buf, 0, RECV_BUFFER_SIZE);

    while (true) {
        // read from uart and store buf
        if (at._mode != ASYN) {
            aos_msleep(1);
        }

        ret = at_getc(&c);
        if (ret != 0) {
            continue;
        }

        if (offset + 1 >= RECV_BUFFER_SIZE) {
            LOGE(MODULE_NAME, "Fatal error, no one is handling AT uart");
            continue;
        }
        buf[offset++] = c;
        buf[offset]   = 0;

        for (int k = 0; k < at._oobs_num; k++) {
            oob = &(at._oobs[k]);
            if (oob->reallen > 0 ||
                (offset >= strlen(oob->prefix) &&
                 memcmp(oob->prefix, buf + offset - strlen(oob->prefix),
                        strlen(oob->prefix)) == 0)) {
                LOGD(MODULE_NAME, "AT! %s\r\n", oob->prefix);
                if (oob->postfix == NULL) {
                    oob->cb(oob->arg, NULL, 0);
                    memset(buf + offset - strlen(oob->prefix), 0, offset);
                    offset -= strlen(oob->prefix);
                } else {
                    if (oob->reallen == 0) {
                        memset(oob->oobinputdata, 0, oob->maxlen);
                        memcpy(oob->oobinputdata, oob->prefix,
                               strlen(oob->prefix) - 1);
                        oob->reallen += strlen(oob->prefix) - 1;
                    }

                    if (oob->reallen < oob->maxlen) {
                        oob->oobinputdata[oob->reallen] = c;
                        oob->reallen++;
                        if ((oob->reallen >=
                             strlen(oob->prefix) + strlen(oob->postfix)) &&
                            (strncmp(oob->oobinputdata + oob->reallen -
                                       strlen(oob->postfix),
                                     oob->postfix,
                                     strlen(oob->postfix)) == 0)) {
                            /*recv postfix*/
                            oob->cb(oob->arg, oob->oobinputdata, oob->reallen);
                            memset(oob->oobinputdata, 0, oob->reallen);
                            oob->reallen = 0;
                            memset(buf, 0, offset);
                            offset = 0;
                        }
                    } else {
                        LOGE(MODULE_NAME,
                             "invalid oob %s input , for oversize %s \r\n",
                             oob->prefix, oob->oobinputdata);
                        memset(oob->oobinputdata, 0, oob->reallen);
                        oob->reallen = 0;
                        memset(buf, 0, offset);
                        offset = 0;
                    }
                    /*oob data maybe more than buf size */
                    if (offset > (RECV_BUFFER_SIZE - 2)) {
                        memset(buf, 0, offset);
                        offset = 0;
                    }
                }
                continue;
            }
        }

        aos_mutex_lock(&at.task_mutex, AOS_WAIT_FOREVER);
        at_task_empty = slist_empty(&at.task_l);

        if (!at_task_empty) {
            tsk = slist_first_entry(&at.task_l, at_task_t, next);
        }
        aos_mutex_unlock(&at.task_mutex);

        // if no task, continue recv
        if (at_task_empty) {
            LOGD(MODULE_NAME, "No task in queue");
            goto check_buffer;
        }

        if (NULL != tsk->rsp_prefix && 0 != tsk->rsp_prefix_len) {
            rsp_prefix     = tsk->rsp_prefix;
            rsp_prefix_len = tsk->rsp_prefix_len;
        } else {
            rsp_prefix     = at._default_recv_prefix;
            rsp_prefix_len = at._recv_prefix_len;
        }

        if (NULL != tsk->rsp_success_postfix &&
            0 != tsk->rsp_success_postfix_len) {
            rsp_success_postfix     = tsk->rsp_success_postfix;
            rsp_success_postfix_len = tsk->rsp_success_postfix_len;
        } else {
            rsp_success_postfix     = at._default_recv_success_postfix;
            rsp_success_postfix_len = at._recv_success_postfix_len;
        }

        if (NULL != tsk->rsp_fail_postfix && 0 != tsk->rsp_fail_postfix_len) {
            rsp_fail_postfix     = tsk->rsp_fail_postfix;
            rsp_fail_postfix_len = tsk->rsp_fail_postfix_len;
        } else {
            rsp_fail_postfix     = at._default_recv_fail_postfix;
            rsp_fail_postfix_len = at._recv_fail_postfix_len;
        }

        if (offset >= rsp_prefix_len && at_task_reponse_begin == 0 &&
            (strncmp(buf + offset - rsp_prefix_len, rsp_prefix,
                     rsp_prefix_len) == 0)) {
            at_task_reponse_begin = 1;
        }

        if (at_task_reponse_begin == 1) {
            if (tsk->rsp_offset < tsk->rsp_len) {
                tsk->rsp[tsk->rsp_offset] = c;
                tsk->rsp_offset++;

                if ((tsk->rsp_offset >= rsp_success_postfix_len &&
                     strncmp(
                       tsk->rsp + tsk->rsp_offset - rsp_success_postfix_len,
                       rsp_success_postfix, rsp_success_postfix_len) == 0) ||
                    (tsk->rsp_offset >= rsp_fail_postfix_len &&
                     strncmp(tsk->rsp + tsk->rsp_offset - rsp_fail_postfix_len,
                             rsp_fail_postfix, rsp_fail_postfix_len) == 0)) {
                    aos_sem_signal(&tsk->smpr);
                    at_task_reponse_begin = 0;
                    memset(buf, 0, offset);
                    offset = 0;
                }
            } else {
                memset(tsk->rsp, 0, tsk->rsp_len);
                strcpy(tsk->rsp, rsp_fail_postfix);
                aos_sem_signal(&tsk->smpr);
                at_task_reponse_begin = 0;
                memset(buf, 0, offset);
                offset = 0;
            }
        }
    check_buffer:
        // in case buffer is full
        if (offset > (RECV_BUFFER_SIZE - 2)) {
            printf("buffer full \r\n");
            memcpy_size = rsp_prefix_len > rsp_success_postfix_len
                            ? rsp_prefix_len
                            : rsp_success_postfix_len;
            memcpy_size = memcpy_size > rsp_fail_postfix_len
                            ? memcpy_size
                            : rsp_fail_postfix_len;
            memcpy(buf, buf + offset - memcpy_size, memcpy_size);
            memset(buf + memcpy_size, 0, offset - memcpy_size);
            offset = memcpy_size;
        }
    }

    return;
}
Ejemplo n.º 10
0
/**
 * Example:
 *          AT+ENETRAWSEND=<len>
 *          ><data>
 *          OK
 *
 * Send data in 2 stages. These 2 stages must be finished inside
 * one mutex lock.
 *   1. Send 'fst' string (first stage);
 *   2. Receving prompt, usually ">" character;
 *   3. Send data (second stage) in 'len' length.
 */
static int at_send_data_2stage(const char *fst, const char *data, uint32_t len,
                               char *rsp, uint32_t rsplen)
{
    int ret = 0;

    if (inited == 0) {
        LOGE(MODULE_NAME, "at have not init yet\r\n");
        return -1;
    }

    if (at._mode != ASYN) {
        LOGE(MODULE_NAME, "Operation not supported in non asyn mode \r\n");
        return -1;
    }

    if (NULL == fst) {
        LOGE(MODULE_NAME, "%s invalid input \r\n", __FUNCTION__);
        return -1;
    }

    if (NULL == rsp || 0 == rsplen) {
        LOGE(MODULE_NAME, "%s invalid input \r\n", __FUNCTION__);
        return -1;
    }

    at_task_t *tsk = (at_task_t *)aos_malloc(sizeof(at_task_t));
    if (NULL == tsk) {
        LOGE(MODULE_NAME, "tsk buffer allocating failed");
        return -1;
    }
    memset(tsk, 0, sizeof(at_task_t));

    if ((ret = aos_sem_new(&tsk->smpr, 0)) != 0) {
        LOGE(MODULE_NAME, "failed to allocate semaphore");
        goto end;
    }

    LOGD(MODULE_NAME, "at task created: %d, smpr: %d", (uint32_t)tsk,
         (uint32_t)&tsk->smpr);

    tsk->command = (char *)fst;
    tsk->rsp     = rsp;
    tsk->rsp_len = rsplen;

    aos_mutex_lock(&at.at_uart_send_mutex, AOS_WAIT_FOREVER);

    at_worker_task_add(tsk);

    // uart operation should be inside mutex lock
#ifdef HDLC_UART
    if ((ret = hdlc_uart_send(&hdlc_encode_ctx, at._pstuart, (void *)fst,
                              strlen(fst), at._timeout, true)) != 0)
#else
    if ((ret = hal_uart_send(at._pstuart, (void *)fst, strlen(fst),
                             at._timeout)) != 0)
#endif
    {
        LOGE(MODULE_NAME, "uart send command failed");
        goto end;
    }
    LOGD(MODULE_NAME, "Sending command %s", fst);

#ifdef HDLC_UART
    if ((ret = hdlc_uart_send(
           &hdlc_encode_ctx, at._pstuart, (void *)at._send_delimiter,
           strlen(at._send_delimiter), at._timeout, false)) != 0)
#else
    if ((ret = hal_uart_send(at._pstuart, (void *)at._send_delimiter,
                             strlen(at._send_delimiter), at._timeout)) != 0)
#endif
    {
        LOGE(MODULE_NAME, "uart send delimiter failed");
        goto end;
    }
    LOGD(MODULE_NAME, "Sending delimiter %s", at._send_delimiter);

#ifdef AT_PARSER_DELAY_FLAG
    aos_msleep(20);
#endif

#ifdef HDLC_UART
    if ((ret = hdlc_uart_send(&hdlc_encode_ctx, at._pstuart, (void *)data, len,
                              at._timeout, true)) != 0)
#else
    if ((ret = hal_uart_send(at._pstuart, (void *)data, len, at._timeout)) != 0)
#endif
    {
        LOGE(MODULE_NAME, "uart send 2stage data failed");
        goto end;
    }

    LOGD(MODULE_NAME, "Sending 2stage data %s", data);

    if ((ret = aos_sem_wait(&tsk->smpr, TASK_DEFAULT_WAIT_TIME)) != 0) {
        LOGE(MODULE_NAME, "sem_wait failed");
        goto end;
    }

    LOGD(MODULE_NAME, "sem_wait succeed.");
end:
    at_worker_task_del(tsk);
    aos_mutex_unlock(&at.at_uart_send_mutex);
    return ret;
}
Ejemplo n.º 11
0
void ssd1306_reset(void)
{
	hal_gpio_output_low(&gpio_oled_reset);
	aos_msleep(1);
	hal_gpio_output_high(&gpio_oled_reset);
}
Ejemplo n.º 12
0
void k_sleep(s32_t duration)
{
    aos_msleep(duration);
}
Ejemplo n.º 13
0
/**
 * @brief   使WiFi模组进入省电模式, 并持续一段时间
 *
 * @param   指定在多长时间内, WiFi模组都处于省电模式, 单位是毫秒
 * @retval  0 : 设置成功
 * @retval  -1 : 设置失败
 *
 * @note sample code
 * int HAL_Wifi_Low_Power(int timeout_ms)
 * {
 *      wifi_enter_power_saving_mode();
 *      msleep(timeout_ms);
 *      wifi_exit_power_saving_mode();
 *
 *      return 0;
 * }
 */
int HAL_Wifi_Low_Power(_IN_ int timeout_ms)
{
    aos_msleep(timeout_ms);
    return 0;
}