2 Commits 3529ddabd8 ... 85fc4be7bc

Autor SHA1 Mensaje Fecha
  basiliscos 85fc4be7bc Merge branch 'mb' of am/cpp-rotor-light into master hace 2 años
  Aliaksei Makarau 81ef9bdaba Update hace 2 años

+ 2 - 0
CMakeLists.txt

@@ -30,6 +30,8 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AVR")
     set(ROTOR_LIGHT_BSP_DIR "avr")
 elseif ("${TOOLCHAIN_PREFIX}" MATCHES "^arm-.*")
     set(ROTOR_LIGHT_BSP_DIR "arm")
+elseif ("${TOOLCHAIN_PREFIX}" STREQUAL "mb-")
+    set(ROTOR_LIGHT_BSP_DIR "mb")
 elseif ("${TOOLCHAIN_PREFIX}" STREQUAL "")
     set(ROTOR_LIGHT_BSP_DIR "host")
 endif()

+ 2 - 3
examples/mb/blink-led.cpp

@@ -11,7 +11,6 @@ namespace message {
 struct BlinkCommand : rl::Message {
   static constexpr auto type_id = __LINE__;
   using rl::Message::Message;
-  rl::MessageTypeId get_type_id() const override { return type_id; }
 };
 
 } // namespace message
@@ -31,11 +30,11 @@ struct Blinker : rl::Actor<2> {
 
   void blink() {
     Board::toggle_led();
-    add_event(
+    add_event<rl::ctx::thread>(
         delay,
         [](void *data) {
           auto self = static_cast<Blinker *>(data);
-          self->send<message::BlinkCommand>(0, self->id);
+          self->send<rl::ctx::thread, message::BlinkCommand>(0, self->id);
         },
         this);
   }

+ 4 - 1
examples/mb/board.cpp

@@ -25,9 +25,10 @@ void TimerCounterHandler(void *CallBackRef, u8 TmrCtrNumber);
 
 static uint32_t gpio_flag = 0xFFFF;
 std::uint64_t gpt_system_tick = 0;
+std::uint32_t gpio_addr;
 
 void Board::toggle_led() {
-  XGpio_Out32(GpioOutput.BaseAddress + XGPIO_DATA_OFFSET, gpio_flag);
+  * ((volatile u32 *) gpio_addr) = gpio_flag;
   gpio_flag ^= 0xFFFF;
 }
 
@@ -56,6 +57,8 @@ void Board::init_start() {
                       TIMER_CNTR_0,
                       XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION);
   XTmrCtr_SetResetValue(&xil_timer, TIMER_CNTR_0, RESET_VALUE);
+
+  gpio_addr = GpioOutput.BaseAddress + XGPIO_DATA_OFFSET;
 }
 
 void Board::enable_interrupts() {

+ 1 - 0
examples/mb/lscript.ld

@@ -18,6 +18,7 @@ _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x800;
 MEMORY
 {
    microblaze_0_local_memory_ilmb_bram_if_cntlr_Mem_microblaze_0_local_memory_dlmb_bram_if_cntlr_Mem : ORIGIN = 0x50, LENGTH = 0x1FFB0
+   axi_bram_ctrl_0_Mem0 : ORIGIN = 0xC0000000, LENGTH = 0x2000
 }
 
 /* Specify the default entry point to the program */

+ 5 - 5
examples/mb/ping-pong-poll.cpp

@@ -9,13 +9,11 @@ namespace message {
 struct Ping : rl::Message {
   using Message::Message;
   static constexpr auto type_id = __LINE__;
-  rl::MessageTypeId get_type_id() const override { return type_id; }
 };
 
 struct Pong : rl::Message {
   using Message::Message;
   static constexpr auto type_id = __LINE__;
-  rl::MessageTypeId get_type_id() const override { return type_id; }
 };
 } // namespace message
 
@@ -34,11 +32,11 @@ struct Pinger : rl::Actor<2> {
 
   void ping() {
     Board::toggle_led();
-    send<message::Ping>(0, ponger_id);
+    send<rl::ctx::thread, message::Ping>(0, ponger_id);
   }
 
   void on_pong(message::Pong &) {
-    add_event(
+    add_event<rl::ctx::thread>(
         1, [](void *data) { static_cast<Pinger *>(data)->ping(); }, this);
   }
 
@@ -52,7 +50,9 @@ struct Ponger : rl::Actor<2> {
     subscribe(&Ponger::on_ping);
     Parent::initialize();
   }
-  void on_ping(message::Ping &) { send<message::Pong>(0, pinger_id); }
+  void on_ping(message::Ping &) {
+    send<rl::ctx::thread, message::Pong>(0, pinger_id);
+  }
   rl::ActorId pinger_id;
 };
 

+ 6 - 0
include/rotor-light/bsp/mb/rotor-light-bsp.h

@@ -0,0 +1,6 @@
+#pragma once
+
+#include <mb_interface.h>
+
+#define ROTOR_LIGHT_ENABLE_INTERRUPTS() microblaze_enable_interrupts()
+#define ROTOR_LIGHT_DISABLE_INTERRUPTS() microblaze_disable_interrupts()