New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added heartbeat functionality #266
e6859f7
fb1b693
a8b7e53
d064f56
8a14bd5
3f726c0
05a9b02
31b424f
3fcf57c
4c99086
e05fa87
03f56cf
115e40c
Diff settings
| @@ -0,0 +1,82 @@ | ||
| #include <generated/csr.h> | ||
| #include <generated/mem.h> | ||
| #include <hw/flags.h> | ||
| #include <system.h> | ||
| #include <time.h> | ||
| #include "heartbeat.h" | ||
| #include "processor.h" | ||
| #include "hdmi_in0.h" | ||
| #include "hdmi_in1.h" | ||
| #include "pattern.h" | ||
| static bool heartbeat_status = false; | ||
| #define HEARTBEAT_FREQUENCY 1 // In Hertz | ||
| #define FILL_RATE 120 // In Hertz, double the standard frame rate | ||
| void hb_status(bool val) | ||
| { | ||
| heartbeat_status = val; | ||
| } | ||
| void hb_service(int sink) | ||
| { | ||
| static int last_event; | ||
| static int counter; | ||
| static bool color_v; | ||
| if (heartbeat_status==1) { | ||
| if(elapsed(&last_event, identifier_frequency_read()/FILL_RATE)) { | ||
| counter = counter+1; | ||
| hb_fill(color_v, sink); | ||
| if(counter > FILL_RATE/(HEARTBEAT_FREQUENCY*2)) { | ||
| color_v = !color_v; | ||
| counter = 0; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| void hb_fill(bool color_v, int sink) | ||
| { | ||
| int addr, i, j; | ||
| unsigned int color; | ||
| volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); | ||
Show comment
Hide comment
mithro
Member
|
||
| #ifdef CSR_HDMI_OUT0_BASE | ||
| if (sink == VIDEO_OUT_HDMI_OUT0) { | ||
| framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_out0_fi_base0_read()); | ||
| } | ||
| #endif | ||
| #ifdef CSR_HDMI_OUT1_BASE | ||
| if (sink == VIDEO_OUT_HDMI_OUT1) { | ||
| framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_out1_fi_base0_read()); | ||
| } | ||
| #endif | ||
| #ifdef ENCODER_BASE | ||
| if (sink == VIDEO_OUT_ENCODER) { | ||
| framebuffer = (unsigned int *)(MAIN_RAM_BASE + encoder_reader_base_read()); | ||
| } | ||
| #endif | ||
| /* | ||
| 8x8 pixel square at right bottom corner | ||
| 8 pixel = 4 memory locations in horizoantal | ||
| 8 pixel = 8 memory locations in vertical | ||
| Toggles between BLUE and RED | ||
| */ | ||
| if (color_v == 0) | ||
| color = YCBCR422_BLUE; | ||
| else | ||
| color = YCBCR422_RED; | ||
| addr = 0 + (processor_h_active/2)*(processor_v_active-8) + (processor_h_active/2) - 4; | ||
| for (i=0; i<4; i++){ | ||
| for (j=0; j<8; j++){ | ||
| framebuffer[addr+i+(processor_h_active/2)*j] = color; | ||
| } | ||
| } | ||
| } | ||
| @@ -0,0 +1,10 @@ | ||
| #ifndef __HEARTBEAT_H | ||
| #define __HEARTBEAT_H | ||
| #include <stdbool.h> | ||
| void hb_status(bool val); | ||
| void hb_service(int sink) ; | ||
| void hb_fill(bool color_v, int sink); | ||
| #endif /* __HEARTBEAT_H */ |
@shenki What does the
volatilehere do? Is it saying the pointer can change out under the compiler - or that the thing that the pointer is pointing too can change out under the compiler?