Beispiel #1
0
int watchdog_refresh()
{
	uchar* fed_addr = ( uchar* )HW_ADDR( WATCHDOG_FED, 0 );
	*fed_addr = WDT_FED_VAL;
	
	return ERR_NONE;
}
Beispiel #2
0
static inline int console_ready_write( Console* cons )
{
	ptr base = console_getbase( cons );
	volatile uint* flags = HW_ADDR( base, UART_FLAG_OFFSET );

	return ( ! ( *flags & TXFF_MASK ) ) && ( ( ! cons->flow_control ) || ( *flags & CTS_MASK ) );
}
Beispiel #3
0
static inline int console_ready_read( Console* cons )
{
	ptr base = console_getbase( cons );
	volatile uint* flags = HW_ADDR( base, UART_FLAG_OFFSET );

	return ( ! ( *flags & RXFE_MASK ) );
}
Beispiel #4
0
int watchdog_deinit()
{
	uchar* ctrl_addr = ( uchar* )HW_ADDR( WATCHDOG_CTRL, 0 );
	watchdog_refresh();
	*ctrl_addr = 0x00;

	return ERR_NONE;
}
Beispiel #5
0
int watchdog_init()
{
	uchar* ctrl_addr = ( uchar* )HW_ADDR( WATCHDOG_CTRL, 0 );
	watchdog_refresh();

	/* Timeout 8 seconds */
	*ctrl_addr = 0x07;
	DEBUG_PRINT( DBG_WATCHDOG, "watchdog initialized to %c\n", ( uchar* )HW_READ( WATCHDOG_CTRL, 0 ) );

	return ERR_NONE;
}
Beispiel #6
0
#include "timer.h"

// Specifies how many timer ticks are in a microsecond.
#define TIMER_USEC	12

// Used for determining the physical address of the timer modules:
#define TIMER_ADDR(hw_addr)	UNSIGNED_DIFF(hw_addr, 0x80000000)

// Information structure for the various timers:
static struct {
	volatile uint32_t * memspace;
	timer_mode_t mode;
	uint32_t usec;
	timer_callback_func callback;
} timers[] = {
	{ HW_ADDR(TIMER0_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER1_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER2_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER3_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER4_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER5_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER6_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER7_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER8_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER9_BASE), TIMER_MODE_NONE, 0, NULL },
	{ HW_ADDR(TIMER10_BASE), TIMER_MODE_NONE, 0, NULL },
};

// Initializes the specified timer:
void timer_reset(int timer, timer_mode_t mode, uint32_t usec, timer_callback_func callback)
{