diff --git a/.github/workflows/act.yml b/.github/workflows/act.yml new file mode 100644 index 0000000..0d5aa16 --- /dev/null +++ b/.github/workflows/act.yml @@ -0,0 +1,11 @@ +name: act-build + +jobs: + act-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: apt-get update + - run: apt install sudo + - run: sudo apt -y install gcc-arm-none-eabi make openocd git + - run: make diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f39dd82..aac916d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,5 +12,5 @@ jobs: steps: - uses: actions/checkout@v3 - run: sudo apt-get update - - run: sudo apt -y install gcc-arm-none-eabi make openocd + - run: sudo apt -y install gcc-arm-none-eabi make openocd git - run: make diff --git a/Makefile b/Makefile index cea9f6e..0196b0d 100644 --- a/Makefile +++ b/Makefile @@ -79,4 +79,7 @@ debug: @openocd -f interface/stlink.cfg -f board/stm32f0discovery.cfg -c "init" & @arm-none-eabi-gdb bin/firmware.elf -x gdbconf -.PHONY: all dep cmsis_core cmsis_f0 build clean dep_clean flash debug +test: + @act --job act-linux + +.PHONY: all dep cmsis_core cmsis_f0 build clean dep_clean flash debug test diff --git a/src/hal/.hal.h.swp b/src/hal/.hal.h.swp new file mode 100644 index 0000000..f3c92e4 Binary files /dev/null and b/src/hal/.hal.h.swp differ diff --git a/src/hal/hal.c b/src/hal/hal.c index 3d3762d..38f20d4 100644 --- a/src/hal/hal.c +++ b/src/hal/hal.c @@ -42,7 +42,7 @@ uint8_t gpio_read(uint16_t pin) void rcc_port_set(uint8_t bank, uint8_t mode) { int n = (17 + bank); - RCC->AHBENR = (RCC->AHBENR & ~BIT(n)) | (mode << n); /* Clear, then set bit. */ + RCC->AHBENR = (RCC->AHBENR & ~BIT(n)) | (uint32_t)(mode << n); /* Clear, then set bit. */ } int timer_expired(uint32_t *t, uint32_t prd, uint32_t now) @@ -71,7 +71,7 @@ void exti_pin_init(uint16_t pin, uint8_t rising, uint8_t priority, func_ptr hand volatile uint32_t *edge_selection = (&EXTI->FTSR - rising); /* Rising/falling edge. */ *edge_selection |= BIT(n); - SYSCFG->EXTICR[n / 4] |= PIN_BANK(pin) << ((n - (4 * (n / 4))) * 4); /* Set source input for respective EXTI line. */ + SYSCFG->EXTICR[n / 4] |= (uint32_t)(PIN_BANK(pin) << ((n - (4 * (n / 4))) * 4)); /* Set source input for respective EXTI line. */ uint8_t irq_pos = n < 2 ? EXTI0_1_IRQn : n < 4 ? EXTI2_3_IRQn : EXTI4_15_IRQn; NVIC_EnableIRQ(irq_pos); diff --git a/src/hal/hal.h b/src/hal/hal.h index 98ee7ce..927bc7f 100644 --- a/src/hal/hal.h +++ b/src/hal/hal.h @@ -21,8 +21,8 @@ #define BIT_LAST(x, y) (x & ((1UL << y) - 1)) /* Last y bits. */ /* uint16_t(2 bytes): upper byte = bank #, lower byte = pin # */ -#define PIN(bank, num) ((((bank) - 'A') << 8) | (num)) /* ex: PIN('C', 7) */ -#define PIN_NUM(pin) ((uint8_t)BIT_LAST(pin, 8)) +#define PIN(bank, num) ((uint16_t)((uint16_t)((uint8_t)(bank) - 'A') << 8UL) | (uint16_t)(num)) +#define PIN_NUM(pin) ((uint8_t)(BIT_LAST(pin, 8))) #define PIN_BANK(pin) ((uint8_t)((pin) >> 8)) /* GPIO input/output modes. */