From 2a4b0e46faf4387a50d906ee705da25fcf2f5b65 Mon Sep 17 00:00:00 2001 From: Barry Carter Date: Tue, 27 Feb 2018 22:02:31 +0000 Subject: [PATCH] Fixup vibrate by enabling clocks. Also move to platform * Add git version * note the new build script too --- Utilities/flash_device_adb.sh | 19 +++++++++++++++++++ buildfw.sh | 12 ------------ hw/platform/snowy_family/snowy_common.c | 10 ++++++++++ hw/platform/snowy_family/snowy_vibrate.c | 22 ++++++++++++++-------- hw/platform/snowy_family/snowy_vibrate.h | 5 +++-- rcore/main.c | 4 +++- 6 files changed, 49 insertions(+), 23 deletions(-) create mode 100755 Utilities/flash_device_adb.sh delete mode 100755 buildfw.sh diff --git a/Utilities/flash_device_adb.sh b/Utilities/flash_device_adb.sh new file mode 100755 index 00000000..3ade9315 --- /dev/null +++ b/Utilities/flash_device_adb.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Push firmware.pbz to the deviceA simple adb push script to get a RebbleOS firmware onto hardware +platform=$1 + +if [[ -z $1 ]]; then + echo "Defaulting to Snowy. Please use '$0 platform' if this isn't what you intended" + platform="snowy" +fi + +echo "I'm going to build platform $platform's PBZ, push it to a connected " +echo "android device over ADB, and then invoke the flash prompt on the pebble app" + +if [ "$platform" != "tintin" ] && [ "$platform" != "snowy" ] && [ "$platform" != "chalk" ]; then + echo "I don't know what platform $1 is!, sorry" + exit 1 +fi +make $platform +adb push ./build/$platform/$platform.pbz /sdcard/Download/ +adb shell am start -n com.getpebble.android.basalt/com.getpebble.android.main.activity.MainActivity -a android.intent.action.VIEW -d file:///sdcard/Download/$platform.pbz diff --git a/buildfw.sh b/buildfw.sh deleted file mode 100755 index 91642196..00000000 --- a/buildfw.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# obtain pebble-firmware-utils from https://github.com/MarSoft/pebble-firmware-utils - -PEBBLE_IMAGE_PATH=~/Pebble/Pebble-4.3-snowy_dvt -PEBBLE_FIRMWARE_UTILS=~/Pebble/pebble-firmware-utils-master - -cp build/snowy/tintin_fw.bin $PEBBLE_IMAGE_PATH/tintin_fw.bin - -sh -c "cd $PEBBLE_IMAGE_PATH && python $PEBBLE_FIRMWARE_UTILS/repackFirmware.py pebble.pbz" -cp -rfv $PEBBLE_IMAGE_PATH/pebble.pbz ./binary/ -curl -T ./binary/pebble.pbz ftp://192.168.0.104:2121 --user user:pass diff --git a/hw/platform/snowy_family/snowy_common.c b/hw/platform/snowy_family/snowy_common.c index c0e5ffda..65afa2c4 100644 --- a/hw/platform/snowy_family/snowy_common.c +++ b/hw/platform/snowy_family/snowy_common.c @@ -16,6 +16,7 @@ #include "FreeRTOS.h" #include "semphr.h" #include "task.h" +#include "snowy_vibrate.h" // ENABLE this if you want smartstrap debugging output. For now if you do this qemu might not work #define DEBUG_UART_SMARTSTRAP @@ -24,6 +25,15 @@ void init_USART3(void); void init_USART8(void); void ss_debug_write(const unsigned char *p, size_t len); + +/* Configs */ +const vibrate_t hw_vibrate_config = { + .pin = GPIO_Pin_4, + .port = GPIOF, + .clock = RCC_AHB1Periph_GPIOF, +}; + + /* * Begin device init */ diff --git a/hw/platform/snowy_family/snowy_vibrate.c b/hw/platform/snowy_family/snowy_vibrate.c index d589fbbd..0e12ad92 100644 --- a/hw/platform/snowy_family/snowy_vibrate.c +++ b/hw/platform/snowy_family/snowy_vibrate.c @@ -6,35 +6,41 @@ */ #include "stm32f4xx.h" +#include "stm32_power.h" #include "stdio.h" #include "string.h" #include "snowy_vibrate.h" #include #include -vibrate_t vibrate = { - .Pin = GPIO_Pin_4, - .Port = GPIOF, -}; +extern const vibrate_t hw_vibrate_config; void hw_vibrate_init(void) { + stm32_power_request(STM32_POWER_AHB1, hw_vibrate_config.clock); + GPIO_InitTypeDef GPIO_InitStructure_Vibr; // init the vibrator GPIO_InitStructure_Vibr.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure_Vibr.GPIO_Pin = vibrate.Pin; + GPIO_InitStructure_Vibr.GPIO_Pin = hw_vibrate_config.pin; GPIO_InitStructure_Vibr.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure_Vibr.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure_Vibr.GPIO_OType = GPIO_OType_PP; - GPIO_Init(vibrate.Port, &GPIO_InitStructure_Vibr); + GPIO_Init(hw_vibrate_config.port, &GPIO_InitStructure_Vibr); + + stm32_power_release(STM32_POWER_AHB1, hw_vibrate_config.clock); } void hw_vibrate_enable(uint8_t enabled) { + stm32_power_request(STM32_POWER_AHB1, hw_vibrate_config.clock); + if (enabled) - GPIO_SetBits(vibrate.Port, vibrate.Pin); + GPIO_SetBits(hw_vibrate_config.port, hw_vibrate_config.pin); else - GPIO_ResetBits(vibrate.Port, vibrate.Pin); + GPIO_ResetBits(hw_vibrate_config.port, hw_vibrate_config.pin); + + stm32_power_release(STM32_POWER_AHB1, hw_vibrate_config.clock); } diff --git a/hw/platform/snowy_family/snowy_vibrate.h b/hw/platform/snowy_family/snowy_vibrate.h index 4b76a2cd..b5a92b24 100644 --- a/hw/platform/snowy_family/snowy_vibrate.h +++ b/hw/platform/snowy_family/snowy_vibrate.h @@ -9,8 +9,9 @@ #include "stm32f4xx.h" typedef struct { - uint16_t Pin; - GPIO_TypeDef *Port; + uint16_t pin; + GPIO_TypeDef *port; + uint32_t clock; } vibrate_t; diff --git a/rcore/main.c b/rcore/main.c index 6d2a7dbb..13583f55 100644 --- a/rcore/main.c +++ b/rcore/main.c @@ -9,6 +9,8 @@ #include "watchdog.h" #include "ambient.h" +extern const char git_version[]; + int main(void) { SystemInit(); @@ -17,7 +19,7 @@ int main(void) rebbleos_init(); - KERN_LOG("main", APP_LOG_LEVEL_INFO, "RebbleOS", VERSION); + KERN_LOG("main", APP_LOG_LEVEL_INFO, "RebbleOS git: %s", git_version); vTaskStartScheduler(); // should never return