F030 works
This commit is contained in:
Родитель
a666e8fc3e
Коммит
4739cbb87f
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
TARGET ?= jd-v0
|
||||
PROF ?= acc
|
||||
PROF ?= servo
|
||||
FORCE ?=
|
||||
|
||||
.SECONDARY: # this prevents object files from being removed
|
||||
|
|
|
@ -7,10 +7,7 @@ static void start_app(void) {
|
|||
|
||||
ctx_t ctx_;
|
||||
|
||||
static const uint8_t output_pins[] = {
|
||||
PIN_LOG0, PIN_LOG1, PIN_LOG2, PIN_LOG3, PIN_LED, PIN_LED2, PIN_PWR,
|
||||
PIN_LED_GND, PIN_GLO0, PIN_GLO1, PIN_ACC_MOSI, PIN_ACC_SCK, PIN_ACC_VCC, PIN_ACC_CS,
|
||||
};
|
||||
static const uint8_t output_pins[] = {OUTPUT_PINS};
|
||||
|
||||
void led_init(void) {
|
||||
for (unsigned i = 0; i < sizeof(output_pins); ++i) {
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -2,11 +2,7 @@
|
|||
|
||||
uint32_t now;
|
||||
|
||||
static const uint8_t output_pins[] = {
|
||||
PIN_LOG0, PIN_LOG1, PIN_LOG2, PIN_LOG3, PIN_LED, PIN_LED2, PIN_PWR,
|
||||
PIN_P0, PIN_P1, PIN_LED_GND, PIN_GLO0, PIN_GLO1, PIN_ACC_MOSI, PIN_ACC_SCK,
|
||||
PIN_ACC_VCC, PIN_ACC_CS, PIN_ASCK, PIN_AMOSI, PA_6,
|
||||
};
|
||||
static const uint8_t output_pins[] = {OUTPUT_PINS};
|
||||
|
||||
void led_init(void) {
|
||||
// To save power, especially in STOP mode,
|
||||
|
@ -29,8 +25,10 @@ void led_init(void) {
|
|||
|
||||
// all power pins are reverse polarity
|
||||
pin_set(PIN_PWR, 1);
|
||||
#ifdef PIN_GLO0
|
||||
pin_set(PIN_GLO0, 1);
|
||||
pin_set(PIN_GLO1, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void log_pin_set(int line, int v) {
|
||||
|
@ -99,7 +97,7 @@ int main(void) {
|
|||
adc_init_random(); // 300b
|
||||
rtc_init();
|
||||
|
||||
//sleep_forever();
|
||||
// sleep_forever();
|
||||
|
||||
txq_init();
|
||||
jd_init();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "jdsimple.h"
|
||||
|
||||
#ifdef PIN_ACC_VCC
|
||||
|
||||
#define REG_CHIP_ID 0x00
|
||||
#define REG_DX 0x01
|
||||
#define REG_DY 0x03
|
||||
|
@ -167,3 +169,5 @@ void acc_hw_init(void) {
|
|||
|
||||
pin_setup_analog_input(PIN_ACC_MISO);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "jdstm.h"
|
||||
|
||||
#ifdef PIN_ACC_SCK
|
||||
|
||||
#define MASK_SET(p) (1 << ((p)&0xf))
|
||||
#define MASK_CLR(p) (1 << (((p)&0xf) + 16))
|
||||
|
||||
|
@ -57,3 +59,5 @@ void bspi_recv(void *dst, uint32_t len) {
|
|||
((uint8_t *)dst)[i] = b;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
14
stm32/pwm.c
14
stm32/pwm.c
|
@ -7,8 +7,10 @@ struct TimDesc {
|
|||
};
|
||||
|
||||
static const struct TimDesc tims[] = {
|
||||
{TIM1, 2, RCC_APB2ENR_TIM1EN}, //
|
||||
{TIM2, 1, RCC_APB1ENR_TIM2EN}, //
|
||||
{TIM1, 2, RCC_APB2ENR_TIM1EN}, //
|
||||
#ifdef TIM2
|
||||
{TIM2, 1, RCC_APB1ENR_TIM2EN},
|
||||
#endif
|
||||
{TIM3, 1, RCC_APB1ENR_TIM3EN}, //
|
||||
{TIM14, 1, RCC_APB1ENR_TIM14EN}, //
|
||||
{TIM16, 2, RCC_APB2ENR_TIM16EN}, //
|
||||
|
@ -23,12 +25,14 @@ struct PinPWM {
|
|||
};
|
||||
|
||||
static const struct PinPWM pins[] = {
|
||||
{PA_1, 2, LL_GPIO_AF_2, TIM2}, // LED on jdm-v2
|
||||
{PA_3, 4, LL_GPIO_AF_2, TIM2}, // POWER on jdm-v2
|
||||
#ifdef TIM2
|
||||
{PA_1, 2, LL_GPIO_AF_2, TIM2}, // LED on jdm-v2
|
||||
{PA_3, 4, LL_GPIO_AF_2, TIM2}, // POWER on jdm-v2
|
||||
{PA_15, 1, LL_GPIO_AF_2, TIM2}, // LED on jdm-v3 (TIM2_CH1_ETR?)
|
||||
#endif
|
||||
//{PA_6, 1, LL_GPIO_AF_5, TIM16}, // SERVO on jdm-v2,3 - doesn't seem to work, TIM3 works
|
||||
{PA_6, 1, LL_GPIO_AF_1, TIM3}, // SERVO on jdm-v2,3
|
||||
{PA_11, 4, LL_GPIO_AF_2, TIM1}, // POWER on jdm-v3
|
||||
{PA_15, 1, LL_GPIO_AF_2, TIM2}, // LED on jdm-v3 (TIM2_CH1_ETR?)
|
||||
{PB_0, 3, LL_GPIO_AF_1, TIM3}, // GLO0 on jdm-v3, also TIM1:2N
|
||||
{PB_1, 1, LL_GPIO_AF_0, TIM14}, // GLO1 on jdm-v3; also TIM3:4, TIM1:3N
|
||||
};
|
||||
|
|
|
@ -9,21 +9,13 @@
|
|||
#define PIN_PWR PA_5
|
||||
#define PIN_P0 -1
|
||||
#define PIN_P1 -1
|
||||
#define PIN_ASCK -1
|
||||
#define PIN_AMOSI -1
|
||||
|
||||
#define PIN_SERVO PA_6
|
||||
|
||||
#define PIN_GLO0 -1
|
||||
#define PIN_GLO1 -1
|
||||
|
||||
#define PIN_ACC_VCC -1
|
||||
#define PIN_ACC_MISO -1
|
||||
#define PIN_ACC_MOSI -1
|
||||
#define PIN_ACC_SCK -1
|
||||
#define PIN_ACC_CS -1
|
||||
#define ACC_PORT GPIOA
|
||||
|
||||
#define UART_PIN PA_9
|
||||
#define UART_PIN_AF LL_GPIO_AF_1
|
||||
#define USART_IDX 1
|
||||
|
||||
#define OUTPUT_PINS \
|
||||
PIN_LOG0, PIN_LOG1, PIN_LOG2, PIN_LOG3, PIN_LED, PIN_LED2, PIN_PWR, PIN_P0, PIN_P1, \
|
||||
PIN_LED_GND, PIN_SERVO,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "jdprofile.h"
|
||||
|
||||
DEVICE_CLASS(0x3beb4448, "JDF030 crank v0");
|
||||
DEVICE_CLASS(0x3f7c8355, "JDF030 crank v0");
|
||||
|
||||
void init_services() {
|
||||
crank_init(PIN_P0, PIN_P1);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#define PIN_SERVO PA_6
|
||||
|
||||
DEVICE_CLASS(0x3beb4448, "JDF030 servo v0");
|
||||
DEVICE_CLASS(0x3faf16db, "JDF030 servo v0");
|
||||
|
||||
void init_services() {
|
||||
servo_init(PIN_SERVO);
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#define PIN_ASCK PA_5
|
||||
#define PIN_AMOSI PA_7
|
||||
|
||||
/*
|
||||
#define PIN_SERVO PA_6
|
||||
/*
|
||||
#define PIN_GLO_SENSE0 PA_1
|
||||
#define PIN_GLO_SENSE1 PA_4
|
||||
*/
|
||||
|
@ -33,3 +33,7 @@
|
|||
#define UART_PIN_AF LL_GPIO_AF_1
|
||||
#define USART_IDX 1
|
||||
|
||||
#define OUTPUT_PINS \
|
||||
PIN_LOG0, PIN_LOG1, PIN_LOG2, PIN_LOG3, PIN_LED, PIN_LED2, PIN_PWR, PIN_P0, PIN_P1, \
|
||||
PIN_LED_GND, PIN_GLO0, PIN_GLO1, PIN_ACC_MOSI, PIN_ACC_SCK, PIN_ACC_VCC, PIN_ACC_CS, \
|
||||
PIN_ASCK, PIN_AMOSI, PIN_SERVO,
|
Загрузка…
Ссылка в новой задаче