mirror of
https://github.com/google/pebble.git
synced 2025-05-29 06:23:13 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
101
platform/silk/boot/src/board/board.h
Normal file
101
platform/silk/boot/src/board/board.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "display.h"
|
||||
|
||||
#include "drivers/button_id.h"
|
||||
|
||||
#include "stm32f4xx_gpio.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define GPIO_Port_NULL ((GPIO_TypeDef *) 0)
|
||||
#define GPIO_Pin_NULL ((uint16_t)0x0000)
|
||||
|
||||
|
||||
typedef struct {
|
||||
//! One of EXTI_PortSourceGPIOX
|
||||
uint8_t exti_port_source;
|
||||
|
||||
//! Value between 0-15
|
||||
uint8_t exti_line;
|
||||
} ExtiConfig;
|
||||
|
||||
typedef struct {
|
||||
const char* const name; ///< Name for debugging purposes.
|
||||
GPIO_TypeDef* const gpio; ///< One of GPIOX. For example, GPIOA.
|
||||
const uint32_t gpio_pin; ///< One of GPIO_Pin_X.
|
||||
ExtiConfig exti;
|
||||
GPIOPuPd_TypeDef pull;
|
||||
} ButtonConfig;
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* const gpio; ///< One of GPIOX. For example, GPIOA.
|
||||
const uint32_t gpio_pin; ///< One of GPIO_Pin_X.
|
||||
} ButtonComConfig;
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* const gpio; ///< One of GPIOX. For example, GPIOA.
|
||||
const uint32_t gpio_pin; ///< One of GPIO_Pin_X.
|
||||
bool active_high; ///< Pin is active high or active low
|
||||
} OutputConfig;
|
||||
|
||||
//! Alternate function pin configuration
|
||||
//! Used to configure a pin for use by a peripheral
|
||||
typedef struct {
|
||||
GPIO_TypeDef* const gpio; ///< One of GPIOX. For example, GPIOA.
|
||||
const uint32_t gpio_pin; ///< One of GPIO_Pin_X.
|
||||
const uint16_t gpio_pin_source; ///< One of GPIO_PinSourceX.
|
||||
const uint8_t gpio_af; ///< One of GPIO_AF_X
|
||||
} AfConfig;
|
||||
|
||||
typedef struct {
|
||||
I2C_TypeDef *const i2c;
|
||||
AfConfig i2c_scl; ///< Alternate Function configuration for SCL pin
|
||||
AfConfig i2c_sda; ///< Alternate Function configuration for SDA pin
|
||||
uint32_t clock_ctrl; ///< Peripheral clock control flag
|
||||
uint32_t clock_speed; ///< Bus clock speed
|
||||
uint32_t duty_cycle; ///< Bus clock duty cycle in fast mode
|
||||
const uint8_t ev_irq_channel; ///< I2C Event interrupt (One of X_IRQn). For example, I2C1_EV_IRQn.
|
||||
const uint8_t er_irq_channel; ///< I2C Error interrupt (One of X_IRQn). For example, I2C1_ER_IRQn.
|
||||
void (* const rail_cfg_fn)(void); //! Configure function for pins on this rail.
|
||||
void (* const rail_ctl_fn)(bool enabled); //! Control function for this rail.
|
||||
} I2cBusConfig;
|
||||
|
||||
typedef enum I2cDevice {
|
||||
I2C_DEVICE_AS3701B,
|
||||
} I2cDevice;
|
||||
|
||||
typedef struct {
|
||||
// I2C Configuration
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
const I2cBusConfig *i2c_bus_configs;
|
||||
const uint8_t i2c_bus_count;
|
||||
const uint8_t *i2c_device_map;
|
||||
const uint8_t i2c_device_count;
|
||||
} BoardConfig;
|
||||
|
||||
// Button Configuration
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct {
|
||||
const ButtonConfig buttons[NUM_BUTTONS];
|
||||
const ButtonComConfig button_com;
|
||||
} BoardConfigButton;
|
||||
|
||||
#include "board_definitions.h"
|
23
platform/silk/boot/src/board/board_definitions.h
Normal file
23
platform/silk/boot/src/board/board_definitions.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if BOARD_SILK
|
||||
#include "board_silk.h"
|
||||
#else
|
||||
#error "Unknown board definition"
|
||||
#endif
|
115
platform/silk/boot/src/board/board_silk.h
Normal file
115
platform/silk/boot/src/board/board_silk.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#define BOARD_LSE_MODE RCC_LSE_Bypass
|
||||
|
||||
#define USE_PARALLEL_FLASH 1 // FIXME PBL-28872: Hack to get the "modern" flash layout.
|
||||
// Fix when we add support for new flash
|
||||
|
||||
#define BOARD_I2C_BUS_COUNT (ARRAY_LENGTH(SILK_I2C_BUS_CONFIGS))
|
||||
|
||||
static const I2cBusConfig SILK_I2C_BUS_CONFIGS[] = {
|
||||
// PMIC I2c
|
||||
[0] = {
|
||||
.i2c = I2C3,
|
||||
.i2c_scl = { GPIOA, GPIO_Pin_8, GPIO_PinSource8, GPIO_AF_I2C3 },
|
||||
.i2c_sda = { GPIOB, GPIO_Pin_8, GPIO_PinSource8, GPIO_AF9_I2C3 },
|
||||
.clock_speed = 400000,
|
||||
.duty_cycle = I2C_DutyCycle_16_9,
|
||||
.clock_ctrl = RCC_APB1Periph_I2C3,
|
||||
.ev_irq_channel = I2C3_EV_IRQn,
|
||||
.er_irq_channel = I2C3_ER_IRQn,
|
||||
},
|
||||
};
|
||||
|
||||
static const uint8_t SILK_I2C_DEVICE_MAP[] = {
|
||||
[I2C_DEVICE_AS3701B] = 0,
|
||||
};
|
||||
|
||||
static const BoardConfig BOARD_CONFIG = {
|
||||
.i2c_bus_configs = SILK_I2C_BUS_CONFIGS,
|
||||
.i2c_bus_count = BOARD_I2C_BUS_COUNT,
|
||||
.i2c_device_map = SILK_I2C_DEVICE_MAP,
|
||||
.i2c_device_count = ARRAY_LENGTH(SILK_I2C_DEVICE_MAP),
|
||||
};
|
||||
|
||||
static const BoardConfigButton BOARD_CONFIG_BUTTON = {
|
||||
.buttons = {
|
||||
[BUTTON_ID_BACK] =
|
||||
{ "Back", GPIOC, GPIO_Pin_13, { EXTI_PortSourceGPIOC, 13 }, GPIO_PuPd_NOPULL },
|
||||
[BUTTON_ID_UP] =
|
||||
{ "Up", GPIOD, GPIO_Pin_2, { EXTI_PortSourceGPIOD, 2 }, GPIO_PuPd_DOWN },
|
||||
[BUTTON_ID_SELECT] =
|
||||
{ "Select", GPIOH, GPIO_Pin_0, { EXTI_PortSourceGPIOH, 0 }, GPIO_PuPd_DOWN },
|
||||
[BUTTON_ID_DOWN] =
|
||||
{ "Down", GPIOH, GPIO_Pin_1, { EXTI_PortSourceGPIOH, 1 }, GPIO_PuPd_DOWN },
|
||||
},
|
||||
|
||||
.button_com = { 0 },
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
QSpiPin_CS,
|
||||
QSpiPin_SCLK,
|
||||
QSpiPin_DQ0,
|
||||
QSpiPin_DQ1,
|
||||
QSpiPin_DQ2,
|
||||
QSpiPin_DQ3,
|
||||
QSpiPinCount,
|
||||
} QSpiPin;
|
||||
|
||||
static const AfConfig BOARD_CONFIG_FLASH_PINS[] = {
|
||||
[QSpiPin_CS] = {
|
||||
.gpio = GPIOB,
|
||||
.gpio_pin = GPIO_Pin_6,
|
||||
.gpio_pin_source = GPIO_PinSource6,
|
||||
.gpio_af = GPIO_AF10_QUADSPI,
|
||||
},
|
||||
[QSpiPin_SCLK] = {
|
||||
.gpio = GPIOB,
|
||||
.gpio_pin = GPIO_Pin_2,
|
||||
.gpio_pin_source = GPIO_PinSource2,
|
||||
.gpio_af = GPIO_AF9_QUADSPI,
|
||||
},
|
||||
[QSpiPin_DQ0] = {
|
||||
.gpio = GPIOC,
|
||||
.gpio_pin = GPIO_Pin_9,
|
||||
.gpio_pin_source = GPIO_PinSource9,
|
||||
.gpio_af = GPIO_AF9_QUADSPI,
|
||||
},
|
||||
[QSpiPin_DQ1] = {
|
||||
.gpio = GPIOC,
|
||||
.gpio_pin = GPIO_Pin_10,
|
||||
.gpio_pin_source = GPIO_PinSource10,
|
||||
.gpio_af = GPIO_AF9_QUADSPI,
|
||||
},
|
||||
[QSpiPin_DQ2] = {
|
||||
.gpio = GPIOC,
|
||||
.gpio_pin = GPIO_Pin_8,
|
||||
.gpio_pin_source = GPIO_PinSource8,
|
||||
.gpio_af = GPIO_AF9_QUADSPI,
|
||||
},
|
||||
[QSpiPin_DQ3] = {
|
||||
.gpio = GPIOA,
|
||||
.gpio_pin = GPIO_Pin_1,
|
||||
.gpio_pin_source = GPIO_PinSource1,
|
||||
.gpio_af = GPIO_AF9_QUADSPI,
|
||||
},
|
||||
};
|
21
platform/silk/boot/src/board/display.h
Normal file
21
platform/silk/boot/src/board/display.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define DISP_COLS 144
|
||||
#define DISP_ROWS 168
|
||||
#define PBL_DISP_SHAPE_RECT
|
Loading…
Add table
Add a link
Reference in a new issue