Commit fb1cb46f authored by Jose Jimenez's avatar Jose Jimenez

fd_stand_alone_main.c & timer.c: Interrupts

debugger_sw/linux/timer.c: Period between interrupts is now directly updated
from the user vaule. Note that this period is always an integer number of
seconds (both in Linux kernel and here in stand-alone)

debugger_sw/fmc-delay/fd_stand_alone_main.c: Some unnecessary stuff removed.
Although Irq routine is short, is better to perform peridic updates outside
the irq routine as the temp. sensor require a conversion time.
Signed-off-by: 's avatarJose Jimenez <ppjm@correo.ugr.es>
parent 48e13ec0
......@@ -13,7 +13,6 @@
#include <dbg.h>
#include "uart.h"
#include "eeprom.h"
#include "fine-delay.h"
#include "hw/fd_channel_regs.h"
#include "hw/fd_main_regs.h"
......@@ -46,13 +45,13 @@ extern uint32_t _HEAP_START;
extern uint32_t _HEAP_END;
int init_iterator=0;
extern int fd_calib_period_s;
int irq_count = 0;
int cali = 0;
#define ENDRAM_MAGIC 0xbadc0ffe
void _irq_entry()
{
irq_count++;
irq_ctrl_pop();
cali++;
clear_irq();
}
......@@ -120,6 +119,7 @@ static void fd_do_reset(struct fd_dev *fd, int hw_reset)
udelay(1000);
}
/* ************** RESET FUNCTION FOR FD ************** */
int fd_reset_again(struct fd_dev *fd)
{
unsigned long j;
......@@ -169,19 +169,13 @@ int main(void)
sdb_find_devices();
uart_init_hw();
mprintf("\nWR-Dbg: starting up...\n");
mprintf("\nWR-Dbg: starting up... cern\n");
usleep_init();
usleep(750*1000);
shell_init();
mprintf("_endram %08x\n", &_endram);
mprintf("_fstack %08x\n", &_fstack);
mprintf("heap %08x\n", &heap);
mprintf("_HEAP_START %08x\n", &_HEAP_START);
mprintf("_HEAP_END %08x\n", &_HEAP_END);
mprintf(
"\n\n**********************************************************\n"
"* FMC DEALY on-SPEC STAND-ALONE NODE *\n"
......@@ -284,10 +278,9 @@ int main(void)
break;
case 9:
if(irq_count >= fd_calib_period_s)
if(cali != 0)
{
irq_count=0;
mprintf("%i, %i, %i\n",irq_count, (irq_count%fd_calib_period_s), !(irq_count%fd_calib_period_s));
cali=0;
fd.temp_timer.function(fd.temp_timer.data);
}
shell_interactive();
......@@ -300,13 +293,12 @@ int main(void)
}
mprintf("\n");
kernel_dev(0,"That thing died, sorry... Shit happens!!!\n");
mprintf(" Don't go crying to your mama!! You are a full grown up.\n"
" Instead of that restart the node.\n"
kernel_dev(0,"That thing died, sorry!!!\n");
mprintf(" Restart the node.\n"
" I'm worried what you just read was *RESET* the node...\n"
" What I wrote was *RESTART* the node (unplug stuff...)\n\n");
mprintf(" This is a beta version, please report bugs to: \n"
" <fmc-delay-1ns-8cha-sa@ohwr.org> \n"
"\nAttach the following info:\n"
" Step %i code %i\n", init_iterator/1000, init_iterator&1000);
" Step %i code %i\n", init_iterator/1000, init_iterator%1000);
}
......@@ -11,8 +11,11 @@
#include "hw/irq_timer.h"
#include <linux/timer.h>
#include <linux/jiffies.h>
#include <dbg.h>
extern unsigned char * BASE_TIMER;
extern int fd_calib_period_s;
int setup_timer(struct timer_list *timer, void (*function)(unsigned long),
unsigned long data)
......@@ -25,15 +28,13 @@ int setup_timer(struct timer_list *timer, void (*function)(unsigned long),
int mod_timer(struct timer_list *timer, unsigned long long expires)
{
uint32_t *dir;
timer->expires=expires;
timer->expires=fd_calib_period_s*0x3B9ACA0;
/* due to time ambiguity */
irq_timer_writel(&timer->itmr, 0x0, TIMER_SEL);
if(expires != timer->itmr.timer_dead_line
|| !irq_timer_check_armed(&timer->itmr))
if(timer->expires != timer->itmr.timer_dead_line
|| !irq_timer_check_armed(&timer->itmr))
{
timer->itmr.timer_dead_line = 0x3B9ACA0;
timer->itmr.timer_dead_line = timer->expires;
irq_timer_set_time(&timer->itmr, timer->itmr.timer_dead_line);
}
if(!irq_timer_check_armed(&timer->itmr))
......@@ -42,5 +43,6 @@ int mod_timer(struct timer_list *timer, unsigned long long expires)
irq_timer_time_mode(&timer->itmr, diff_time_periodic);
irq_timer_arm(&timer->itmr, timer_arm);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment