|
1 | 1 | /////////////////////////////////////////////////////////////////////////////// |
2 | | -// Copyright Christopher Kormanyos 2025. |
| 2 | +// Copyright Christopher Kormanyos 2007 - 2025. |
3 | 3 | // Distributed under the Boost Software License, |
4 | 4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt |
5 | 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | 6 | // |
7 | 7 |
|
8 | | -#include <mcal_led/mcal_led_boolean_state_base.h> |
9 | 8 | #include <mcal_led.h> |
10 | | -#include <mcal_reg.h> |
11 | | -#include <util/utility/util_time.h> |
12 | | - |
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 |
26 | | - |
27 | | -class led_port_tmp_bl606 : public mcal::led::led_boolean_state_base |
28 | | -{ |
29 | | -public: |
30 | | - led_port_tmp_bl606() noexcept |
31 | | - { |
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(); |
43 | | - } |
44 | | - |
45 | | - ~led_port_tmp_bl606() override = default; |
46 | | - |
47 | | - auto toggle() noexcept -> void override |
48 | | - { |
49 | | - // Toggle the IO3 pin. |
50 | | - // glb->GPIO_CFGCTL32.bit.reg_gpio_3_o ^= 1ul; |
51 | | - mcal::reg::reg_access_static<std::uintptr_t, std::uint32_t, mcal::reg::gpio_cfgctl32, UINT32_C(3)>::bit_not(); |
52 | | - |
53 | | - using base_class_type = led_boolean_state_base; |
54 | | - |
55 | | - base_class_type::toggle(); |
56 | | - } |
57 | | -}; |
| 9 | +#include <mcal_led/mcal_led_port.h> |
58 | 10 |
|
59 | 11 | auto mcal::led::led0() -> mcal::led::led_base& |
60 | 12 | { |
61 | | - using led0_led_type = led_port_tmp_bl606; |
| 13 | + using led0_port_type = mcal::port::port_pin<unsigned { UINT8_C(3) }>; |
| 14 | + |
| 15 | + using led0_led_type = mcal::led::led_port<led0_port_type>; |
62 | 16 |
|
63 | 17 | static led0_led_type l0; |
64 | 18 |
|
65 | 19 | return l0; |
66 | 20 | } |
67 | | - |
0 commit comments