Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: allow for leaner base and STM32F1 support #706

Merged
merged 3 commits into from Feb 26, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1229,11 +1229,6 @@ TNumber pow(TNumber x, TNumber y) {
#endif
}

//%
TNumber atan2(TNumber y, TNumber x) {
return fromDouble(::atan2(toDouble(y), toDouble(x)));
}

NUMBER randomDouble() {
return getRandom(UINT_MAX) / ((NUMBER)UINT_MAX + 1) +
getRandom(0xffffff) / ((NUMBER)UINT_MAX * 0xffffff);
@@ -1282,27 +1277,6 @@ TNumber log(TNumber x){SINGLE(log)}
//%
TNumber log10(TNumber x){SINGLE(log10)}

//%
TNumber tan(TNumber x){SINGLE(tan)}

//%
TNumber sin(TNumber x){SINGLE(sin)}

//%
TNumber cos(TNumber x){SINGLE(cos)}

//%
TNumber atan(TNumber x){SINGLE(atan)}

//%
TNumber asin(TNumber x){SINGLE(asin)}

//%
TNumber acos(TNumber x){SINGLE(acos)}

//%
TNumber sqrt(TNumber x){SINGLE(sqrt)}

//%
TNumber floor(TNumber x){SINGLE(floor)}

@@ -10,6 +10,7 @@
"pxtbase.h",
"core.cpp",
"advmath.cpp",
"trig.cpp",
"pxt-helpers.ts",
"buffer.cpp",
"buffer.ts",
@@ -0,0 +1,37 @@
#include "pxtbase.h"
#include <limits.h>
#include <stdlib.h>

using namespace std;

namespace pxt {

#define SINGLE(op) return fromDouble(::op(toDouble(x)));

//%
TNumber atan2(TNumber y, TNumber x) {
return fromDouble(::atan2(toDouble(y), toDouble(x)));
}

//%
TNumber tan(TNumber x){SINGLE(tan)}

//%
TNumber sin(TNumber x){SINGLE(sin)}

//%
TNumber cos(TNumber x){SINGLE(cos)}

//%
TNumber atan(TNumber x){SINGLE(atan)}

//%
TNumber asin(TNumber x){SINGLE(asin)}

//%
TNumber acos(TNumber x){SINGLE(acos)}

//%
TNumber sqrt(TNumber x){SINGLE(sqrt)}

}
@@ -5,15 +5,22 @@

namespace pxt {

#ifdef STM32F1
STMLowLevelTimer lowTimer(TIM4, TIM4_IRQn);
#else
STMLowLevelTimer lowTimer(TIM5, TIM5_IRQn);
#endif

CODAL_TIMER devTimer(lowTimer);

void initAccelRandom();

static void initRandomSeed() {
#ifdef STM32F4
if (getConfig(CFG_ACCELEROMETER_TYPE, -1) != -1) {
initAccelRandom();
}
#endif
}

static void set_if_present(int cfg, int val) {
@@ -28,10 +35,12 @@ void deepSleep() {
// doesn't do
CodalComponent::setAllSleep(true);

#ifdef STM32F4
// ask bootloader to do the deep sleeping
QUICK_BOOT(1);
RTC->BKP1R = 0x10b37889;
NVIC_SystemReset();
#endif
}

void platformSendSerial(const char *data, int len) {
@@ -64,12 +73,14 @@ void platform_init() {
}

int *getBootloaderConfigData() {
#ifdef STM32F4
auto config_data = (uint32_t)(UF2_BINFO->configValues);
if (config_data && (config_data & 3) == 0) {
auto p = (uint32_t *)config_data - 4;
if (p[0] == CFG_MAGIC0 && p[1] == CFG_MAGIC1)
return (int *)p + 4;
}
#endif

return NULL;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.