Skip to content

Commit

Permalink
More modernize avr-mcal and some utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Aug 6, 2024
1 parent c8c4e7f commit fc85e0f
Show file tree
Hide file tree
Showing 40 changed files with 384 additions and 721 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ while core 0 enters an endless, idle loop.
Ozone debug files are supplied for this system for those interested.
Reverse engineering of the complicated (and scantly documented)
dual-core startup originated in and have been taken from (with many thanks)
[Chalandi/Blinky_Pico_dual_core_nosdk](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk).
from the `Blinky_Pico_dual_core_nosdk`
[repo](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk).

Target `v850es_fx2` uses a classic Renesas(R) V850es/Fx2 core.
The upd703231 microcontroller derivative on an F-Line _Drive_ _It_
Expand Down
1 change: 0 additions & 1 deletion ref_app/ref_app.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,6 @@
<ClInclude Include="src\util\utility\util_alignas.h" />
<ClInclude Include="src\util\utility\util_baselexical_cast.h" />
<ClInclude Include="src\util\utility\util_bit_mask.h" />
<ClInclude Include="src\util\utility\util_circular_buffer.h" />
<ClInclude Include="src\util\utility\util_communication.h" />
<ClInclude Include="src\util\utility\util_constexpr_algorithm_unsafe.h" />
<ClInclude Include="src\util\utility\util_constexpr_cmath_unsafe.h" />
Expand Down
3 changes: 0 additions & 3 deletions ref_app/ref_app.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,6 @@
<ClInclude Include="src\util\memory\util_static_allocator.h">
<Filter>src\util\memory</Filter>
</ClInclude>
<ClInclude Include="src\util\utility\util_circular_buffer.h">
<Filter>src\util\utility</Filter>
</ClInclude>
<ClInclude Include="src\mcal\stm32f100\mcal_port.h">
<Filter>src\mcal\stm32f100</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion ref_app/src/mcal/avr/mcal_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <mcal_port.h>
#include <mcal_wdg.h>

void mcal::cpu::init()
auto mcal::cpu::init() -> void
{
mcal::wdg::init(nullptr);
mcal::port::init(nullptr);
Expand Down
12 changes: 6 additions & 6 deletions ref_app/src/mcal/avr/mcal_cpu.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2020.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_CPU_2009_02_14_H_
#define MCAL_CPU_2009_02_14_H_
#ifndef MCAL_CPU_2009_02_14_H
#define MCAL_CPU_2009_02_14_H

#include <cstdint>

Expand All @@ -16,10 +16,10 @@
{
void init();

inline void post_init() { }
inline auto post_init() -> void { }

inline void nop() noexcept { asm volatile("nop"); }
inline auto nop() noexcept -> void { asm volatile("nop"); }
}
}

#endif // MCAL_CPU_2009_02_14_H_
#endif // MCAL_CPU_2009_02_14_H
25 changes: 17 additions & 8 deletions ref_app/src/mcal/avr/mcal_eep.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2018 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_cpu.h>
#include <mcal_eep.h>
#include <mcal_reg.h>

namespace
namespace local
{
bool mcal_eep_is_busy()
auto mcal_eep_is_busy() -> bool;

auto mcal_eep_is_busy() -> bool
{
return (mcal::reg::reg_access_static<std::uint8_t,
std::uint8_t,
mcal::reg::eecr,
UINT8_C(1)>::bit_get() == true);
}
}
} // namespace local

void mcal::eep::init(const config_type*)
auto mcal::eep::init(const config_type*) -> void
{
}

void mcal::eep::write(const address_type addr, const std::uint8_t data)
auto mcal::eep::write(const address_type addr, const std::uint8_t data) -> void
{
while(mcal_eep_is_busy())
while(local::mcal_eep_is_busy())
{
mcal::cpu::nop();
}
Expand All @@ -45,9 +54,9 @@ void mcal::eep::write(const address_type addr, const std::uint8_t data)
UINT8_C(1)>::bit_set();
}

std::uint8_t mcal::eep::read(const address_type addr)
auto mcal::eep::read(const address_type addr) -> std::uint8_t
{
while(mcal_eep_is_busy())
while(local::mcal_eep_is_busy())
{
mcal::cpu::nop();
}
Expand Down
19 changes: 13 additions & 6 deletions ref_app/src/mcal/avr/mcal_eep.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#ifndef MCAL_EEP_2018_12_15_H_
#define MCAL_EEP_2018_12_15_H_
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2018 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_EEP_2018_12_15_H
#define MCAL_EEP_2018_12_15_H

#include <cstdint>

Expand All @@ -10,11 +17,11 @@
using config_type = void;
using address_type = std::uint_fast16_t;

void init(const config_type*);
auto init(const config_type*) -> void;

void write(const address_type addr, const std::uint8_t data);
std::uint8_t read (const address_type addr);
auto write(const address_type addr, const std::uint8_t data)-> void;
auto read (const address_type addr) -> std::uint8_t;
}
}

#endif // MCAL_EEP_2018_12_15_H_
#endif // MCAL_EEP_2018_12_15_H
2 changes: 1 addition & 1 deletion ref_app/src/mcal/avr/mcal_gpt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down
4 changes: 2 additions & 2 deletions ref_app/src/mcal/avr/mcal_irq.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_irq.h>

void mcal::irq::init(const config_type*)
auto mcal::irq::init(const config_type*) -> void
{
mcal::irq::enable_all();
}
14 changes: 7 additions & 7 deletions ref_app/src/mcal/avr/mcal_irq.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_IRQ_2010_04_10_H_
#define MCAL_IRQ_2010_04_10_H_
#ifndef MCAL_IRQ_2010_04_10_H
#define MCAL_IRQ_2010_04_10_H

namespace mcal
{
namespace irq
{
typedef void config_type;

void init(const config_type*);
auto init(const config_type*) -> void;

inline void enable_all () noexcept { asm volatile("sei"); }
inline void disable_all() noexcept { asm volatile("cli"); }
inline auto enable_all () noexcept -> void { asm volatile("sei"); }
inline auto disable_all() noexcept -> void { asm volatile("cli"); }
}
}

#endif // MCAL_IRQ_2010_04_10_H_
#endif // MCAL_IRQ_2010_04_10_H
4 changes: 2 additions & 2 deletions ref_app/src/mcal/avr/mcal_led.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2020.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -8,7 +8,7 @@
#include <mcal_led.h>
#include <mcal_led/mcal_led_port.h>

mcal::led::led_base& mcal::led::led0()
auto mcal::led::led0() -> mcal::led::led_base&
{
using led0_port_type = mcal::port::port_pin<std::uint8_t,
std::uint8_t,
Expand Down
2 changes: 1 addition & 1 deletion ref_app/src/mcal/avr/mcal_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
namespace led
{
led_base& led0();
auto led0() -> led_base&;
}
}

Expand Down
8 changes: 4 additions & 4 deletions ref_app/src/mcal/avr/mcal_memory_progmem.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2019 - 2023.
// Copyright Christopher Kormanyos 2019 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H_
#define MCAL_MEMORY_PROGMEM_2019_08_17_H_
#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H
#define MCAL_MEMORY_PROGMEM_2019_08_17_H

#include <stddef.h>

Expand Down Expand Up @@ -59,4 +59,4 @@
}
#endif

#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H_
#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H
31 changes: 19 additions & 12 deletions ref_app/src/mcal/avr/mcal_memory_sram_parallel_cypress_cy62158e.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#ifndef MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_
#define MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2020 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H
#define MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H

#include <array>
#include <cstddef>
Expand Down Expand Up @@ -28,7 +35,7 @@
private:
// The CY62158E MoBL(R)is a high performance CMOS static RAM
// organized as 1024K words by 8 bits (i.e., 1 Mbyte).
static void nibble_port_pin_functions(const std::uint8_t nibble_value)
static auto nibble_port_pin_functions(const std::uint8_t nibble_value) -> void
{
switch(nibble_value)
{
Expand All @@ -52,7 +59,7 @@
}

public:
memory_sram_parallel_cypress_cy62158e() : my_word16_addr_04_to_19(0U)
memory_sram_parallel_cypress_cy62158e()
{
// Initialize the parallel sram control pins.
sram_parallel_port_pin_ce1_not_type::set_pin_high();
Expand Down Expand Up @@ -92,7 +99,7 @@

~memory_sram_parallel_cypress_cy62158e() = default;

void write(const std::uint32_t address_to_write, const std::uint8_t source_byte_to_write)
auto write(const std::uint32_t address_to_write, const std::uint8_t source_byte_to_write) -> void
{
// According to Document Number: 38-05684 Rev. *L:
// To write to the device, take Chip Enables (CE1_NOT LOW and CE2
Expand Down Expand Up @@ -151,9 +158,9 @@
sram_parallel_port_word08_data_type::set_direction_input();
}

void write_n(const std::uint32_t address_to_write,
auto write_n(const std::uint32_t address_to_write,
const std::size_t count,
const std::uint8_t* source_input_to_write)
const std::uint8_t* source_input_to_write) -> void
{
// Write n bytes, when n can be 1 but should
// be greater than 1 for improved efficiency.
Expand Down Expand Up @@ -226,7 +233,7 @@
sram_parallel_port_word08_data_type::set_direction_input();
}

std::uint8_t read(const std::uint32_t address_to_read)
auto read(const std::uint32_t address_to_read) -> std::uint8_t
{
// According to Document Number: 38-05684 Rev. *L:
// To read from the device, take Chip Enables (CE1_NOT LOW and CE2
Expand Down Expand Up @@ -280,9 +287,9 @@
return byte_to_read;
}

void read_n(const std::uint32_t address_to_read,
auto read_n(const std::uint32_t address_to_read,
const std::size_t count,
std::uint8_t* dest_to_store_read_data)
std::uint8_t* dest_to_store_read_data) -> void
{
// Read n bytes, when n can be 1 but should
// be greater than 1 for improved efficiency.
Expand Down Expand Up @@ -349,9 +356,9 @@
}

private:
std::uint16_t my_word16_addr_04_to_19;
std::uint16_t my_word16_addr_04_to_19 { };
};

} } } // namespace mcal::memory::sram

#endif // MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_
#endif // MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H
4 changes: 2 additions & 2 deletions ref_app/src/mcal/avr/mcal_osc.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_osc.h>

void mcal::osc::init(const config_type*)
auto mcal::osc::init(const config_type*) -> void
{
}
6 changes: 3 additions & 3 deletions ref_app/src/mcal/avr/mcal_osc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -12,9 +12,9 @@
{
namespace osc
{
typedef void config_type;
using config_type = void;

void init(const config_type*);
auto init(const config_type*) -> void;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ref_app/src/mcal/avr/mcal_port.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_port.h>

void mcal::port::init(const config_type*)
auto mcal::port::init(const config_type*) -> void
{
}
Loading

0 comments on commit fc85e0f

Please sign in to comment.