|
5 | 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | 6 | // |
7 | 7 |
|
8 | | -#include <mcal_led.h> |
9 | 8 | #include <mcal_led/mcal_led_boolean_state_base.h> |
| 9 | +#include <mcal_led.h> |
10 | 10 | #include <mcal_reg.h> |
11 | 11 | #include <util/utility/util_time.h> |
12 | 12 |
|
13 | | -#include "BL602.h" |
14 | | - |
15 | | -#include <cstdint> |
| 13 | +namespace |
| 14 | +{ |
| 15 | + constexpr std::uint32_t GPIO_FUN_SDIO { UINT32_C( 1) }; |
| 16 | + constexpr std::uint32_t GPIO_FUN_FLASH { UINT32_C( 2) }; |
| 17 | + constexpr std::uint32_t GPIO_FUN_SPI { UINT32_C( 4) }; |
| 18 | + constexpr std::uint32_t GPIO_FUN_I2C { UINT32_C( 6) }; |
| 19 | + constexpr std::uint32_t GPIO_FUN_UART { UINT32_C( 7) }; |
| 20 | + constexpr std::uint32_t GPIO_FUN_PWM { UINT32_C( 8) }; |
| 21 | + constexpr std::uint32_t GPIO_FUN_EXT_PA { UINT32_C( 9) }; |
| 22 | + constexpr std::uint32_t GPIO_FUN_ANALOG { UINT32_C(10) }; |
| 23 | + constexpr std::uint32_t GPIO_FUN_SWGPIO { UINT32_C(11) }; |
| 24 | + constexpr std::uint32_t GPIO_FUN_JTAG { UINT32_C(14) }; |
| 25 | +} // anonymous namespace |
16 | 26 |
|
17 | 27 | class led_port_tmp_bl606 : public mcal::led::led_boolean_state_base |
18 | 28 | { |
19 | 29 | public: |
20 | 30 | led_port_tmp_bl606() noexcept |
21 | 31 | { |
22 | | - /* configure IO3 as output */ |
23 | | - glb->GPIO_CFGCTL1.bit.reg_gpio_3_func_sel = GPIO_FUN_SWGPIO; |
24 | | - glb->GPIO_CFGCTL1.bit.reg_gpio_3_ie = 0ul; |
25 | | - glb->GPIO_CFGCTL1.bit.reg_gpio_3_drv = 0ul; |
26 | | - glb->GPIO_CFGCTL1.bit.reg_gpio_3_smt = 0ul; |
27 | | - glb->GPIO_CFGCTL34.bit.reg_gpio_3_oe = 1ul; |
| 32 | + // Configure IO3 as output, low. |
| 33 | + // glb->GPIO_CFGCTL1.bit.reg_gpio_3_func_sel = GPIO_FUN_SWGPIO; |
| 34 | + // glb->GPIO_CFGCTL1.bit.reg_gpio_3_ie = 0ul; |
| 35 | + // glb->GPIO_CFGCTL1.bit.reg_gpio_3_smt = 0ul; |
| 36 | + // glb->GPIO_CFGCTL1.bit.reg_gpio_3_drv = 0ul; |
| 37 | + // glb->GPIO_CFGCTL34.bit.reg_gpio_3_oe = 1ul; |
| 38 | + mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl1, static_cast<std::uint32_t>(GPIO_FUN_SWGPIO << 24U)>::template reg_msk<static_cast<std::uint32_t>(UINT32_C(0xF) << 24U)>(); |
| 39 | + mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl1, UINT32_C(16)>::bit_clr(); |
| 40 | + mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl1, UINT32_C(17)>::bit_clr(); |
| 41 | + mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl1, UINT32_C(0) << 18U>::template reg_msk<UINT32_C(3) << 18U>(); |
| 42 | + mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl34, UINT32_C(3)>::bit_set(); |
28 | 43 | } |
29 | 44 |
|
30 | 45 | ~led_port_tmp_bl606() override = default; |
31 | 46 |
|
32 | 47 | auto toggle() noexcept -> void override |
33 | 48 | { |
34 | | - using base_class_type = led_boolean_state_base; |
35 | | - |
36 | 49 | // Toggle the IO3 pin. |
| 50 | + // glb->GPIO_CFGCTL32.bit.reg_gpio_3_o ^= 1ul; |
37 | 51 | mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl32, UINT32_C(3)>::bit_not(); |
38 | | - //glb->GPIO_CFGCTL32.bit.reg_gpio_3_o ^= 1ul; |
| 52 | + |
| 53 | + using base_class_type = led_boolean_state_base; |
39 | 54 |
|
40 | 55 | base_class_type::toggle(); |
41 | 56 | } |
|
0 commit comments