-
Notifications
You must be signed in to change notification settings - Fork 70
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
Changes from 10 commits
e6859f7
fb1b693
a8b7e53
d064f56
8a14bd5
3f726c0
05a9b02
31b424f
3fcf57c
4c99086
e05fa87
03f56cf
115e40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ OBJECTS=isr.o \ | |
hdmi_in1.o \ | ||
hdmi_out0.o \ | ||
hdmi_out1.o \ | ||
heartbeat.o \ | ||
pattern.o \ | ||
edid.o \ | ||
pll.o \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
#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 int heartbeat_status = 0; | ||
|
||
void hb_status(int val) | ||
{ | ||
if(val==1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, can't you just do void hb_status(bool new_status)
{
heartbeat_status = new_status;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was gonna be my next natural step. Corrected. |
||
heartbeat_status = 1; | ||
} | ||
else { | ||
heartbeat_status = 0; | ||
} | ||
} | ||
|
||
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()/120)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you dividing by 120 here? I assume it is to get a certain frequency? Maybe you should do; #define HEARTBEAT_FREQUENCY 20 // In Hertz There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increasing this number seemed to be fixing the glitch. Which I suppose was because, we were not filling frames fast enough. Assuming a 60Hz output, setting this to 120, means we are filling frames at double the input rate. Any ways I have added the required definitions now. |
||
counter = counter+1; | ||
hb_fill(color_v, sink); | ||
if(counter>60){ | ||
color_v = !color_v; | ||
counter = 0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra new line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corrected. |
||
} | ||
} | ||
} | ||
|
||
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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shenki What does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
#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 the colors defined in color_bar array from pattern.c | ||
*/ | ||
if (color_v == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indenting... |
||
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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __HEARTBEAT_H | ||
#define __HEARTBEAT_H | ||
|
||
#include <stdbool.h> | ||
|
||
void hb_status(int val); | ||
void hb_service(int sink) ; | ||
void hb_fill(bool color_v, int sink); | ||
|
||
#endif /* __HEARTBEAT_H */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a bool for heartbeat_status rather than an int?