Bugfix in 'machine.UART'

Updated 'machine' module
Removed unused random.c & random.h
This commit is contained in:
Boris Lovosevic
2018-02-05 18:14:30 +01:00
parent 5bc0b0b85d
commit 6a8e7bf8be
25 changed files with 410 additions and 108 deletions
+3
View File
@@ -352,6 +352,9 @@ check_Environment() {
tar -xf esp-idf.tar.xz > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "unpacking 'esp-idf' FAILED"
if [ "${machine}" == "Win" ]; then
echo "On Windows, it may be a false error, run './BUILD.sh menuconfig' again!"
fi
return 1
fi
fi
@@ -1,83 +0,0 @@
/*
* Copyright (c) 2016, Pycom Limited.
*
* This software is licensed under the GNU GPL version 3 or any
* later version, with permitted additional terms. For more information
* see the Pycom Licence v1.0 document supplied with this file, or
* available at https://www.pycom.io/opensource/licensing
*/
#include <stdint.h>
#include "py/obj.h"
#include "random.h"
#include "esp_system.h"
/******************************************************************************
* LOCAL TYPES
******************************************************************************/
typedef union _rng_id_t {
uint32_t id32;
uint16_t id16[3];
uint8_t id8[6];
} rng_id_t;
/******************************************************************************
* LOCAL VARIABLES
******************************************************************************/
static uint32_t s_seed;
/******************************************************************************
* LOCAL FUNCTION DECLARATIONS
******************************************************************************/
STATIC uint32_t lfsr (uint32_t input);
/******************************************************************************
* PRIVATE FUNCTIONS
******************************************************************************/
STATIC uint32_t lfsr (uint32_t input) {
return (input >> 1) ^ (-(input & 0x01) & 0x00E10000);
}
/******************************************************************************/
// Micro Python bindings;
STATIC mp_obj_t machine_rng_get(void) {
return mp_obj_new_int(rng_get());
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_rng_get_obj, machine_rng_get);
/******************************************************************************
* PUBLIC FUNCTIONS
******************************************************************************/
void rng_init0 (void) {
// FIXME
rng_id_t juggler;
// uint32_t seconds;
// uint16_t mseconds;
// get the seconds and the milliseconds from the RTC
// pyb_rtc_get_time(&seconds, &mseconds);
esp_efuse_mac_get_default(juggler.id8);
// flatten the 48-bit board identification to 24 bits
juggler.id16[0] ^= juggler.id16[2];
juggler.id8[0] ^= juggler.id8[3];
juggler.id8[1] ^= juggler.id8[4];
juggler.id8[2] ^= juggler.id8[5];
s_seed = juggler.id32 & 0x00FFFFFF;
// s_seed += (seconds & 0x000FFFFF) + mseconds;
// the seed must never be zero
if (s_seed == 0) {
s_seed = 1;
}
}
uint32_t rng_get (void) {
s_seed = lfsr( s_seed );
return s_seed;
}
@@ -1,18 +0,0 @@
/*
* Copyright (c) 2016, Pycom Limited.
*
* This software is licensed under the GNU GPL version 3 or any
* later version, with permitted additional terms. For more information
* see the Pycom Licence v1.0 document supplied with this file, or
* available at https://www.pycom.io/opensource/licensing
*/
#ifndef __RANDOM_H
#define __RANDOM_H
void rng_init0 (void);
uint32_t rng_get (void);
MP_DECLARE_CONST_FUN_OBJ_0(machine_rng_get_obj);
#endif // __RANDOM_H
@@ -183,7 +183,7 @@ static void uart_event_task(void *pvParameters)
mp_obj_t tuple[3];
tuple[0] = mp_obj_new_int(self->uart_num+1);
tuple[1] = mp_obj_new_int(UART_CB_TYPE_DATA);
tuple[2] = mp_obj_new_str((const char*)dtmp, datasize, 0);
tuple[2] = mp_obj_new_str((const char*)dtmp, self->data_cb_size, 0);
mp_sched_schedule(self->data_cb, mp_obj_new_tuple(3, tuple));
}
else if (self->pattern_cb) {
@@ -195,6 +195,11 @@ STATIC mp_obj_t machine_deepsleep(size_t n_args, const mp_obj_t *pos_args, mp_ma
if (expiry > 0) {
esp_deep_sleep_enable_timer_wakeup((uint64_t)(expiry * 1000));
}
else {
if ((machine_rtc_config.ext0_pin < 0) && (machine_rtc_config.ext1_pins == 0) && (!machine_rtc_config.wake_on_touch)) {
mp_raise_ValueError("No other wake-up sources configured, sleep time cannot be 0 !");
}
}
if (machine_rtc_config.ext0_pin != -1) {
esp_deep_sleep_enable_ext0_wakeup(machine_rtc_config.ext0_pin, machine_rtc_config.ext0_level ? 1 : 0);
@@ -224,8 +229,8 @@ STATIC mp_obj_t machine_wake_reason (void) {
mpsleep_wake_reason_t wake_reason = mpsleep_get_wake_reason();
mp_obj_t tuple[2];
tuple[0] = mp_obj_new_int(wake_reason);
tuple[1] = mp_obj_new_int(reset_reason);
tuple[0] = mp_obj_new_int(reset_reason);
tuple[1] = mp_obj_new_int(wake_reason);
return mp_obj_new_tuple(2, tuple);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_wake_reason_obj, machine_wake_reason);
@@ -1,8 +1,8 @@
// MicroPython version info
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.16"
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.17"
#define MICROPY_GIT_HASH "gdaa8cfa8"
#define MICROPY_BUILD_DATE "2017-02-04"
#define MICROPY_BUILD_DATE "2017-02-05"
#define MICROPY_VERSION_MAJOR (3)
#define MICROPY_VERSION_MINOR (1)
#define MICROPY_VERSION_MICRO (16)
#define MICROPY_VERSION_STRING "3.1.16"
#define MICROPY_VERSION_MICRO (17)
#define MICROPY_VERSION_STRING "3.1.17"
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More