OpenCores
URL https://opencores.org/ocsvn/light52/light52/trunk

Subversion Repositories light52

[/] [light52/] [trunk/] [test/] [common/] [soc.h] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ja_rd
/**
2
    @file soc.h
3
    @brief Hardware-dependent function library.
4
 
5
    This file encapsulates hardware access from the rest of the program for
6
    easier porting.
7
*/
8
 
9
#ifndef SOC_H_INCLUDED
10
#define SOC_H_INCLUDED
11
 
12
#include <stdint.h>
13
#include <stdbool.h>
14
 
15
/*-- SoC configuration macros ------------------------------------------------*/
16
/* These may optionally be set at the makefile */
17
 
18
#ifndef CLOCK_RATE
19
/** Default clock rate is that of Terasic's DE-1 board */
20
#define CLOCK_RATE (50e6)
21
#endif  
22
 
23
#ifndef TIMER0_PRESCALER
24
/** By default the prescaler is set to count periods of 20us @ 50MHz */
25
#define TIMER0_PRESCALER (1000)
26
#endif
27
 
28
/*-- Public functions --------------------------------------------------------*/
29
 
30
 
31
 
32
/*-- SoC ----------------------------------------------------------*/
33
 
34
 
35
/**
36
    Set up all the MCU peripherals with a standard cofiguration.
37
    This includes:
38
    -# Timer 0 set to count seconds (when prescaler set to 20us).
39
    -# UART in default configuration (19200-8-N-1).
40
*/
41
extern void soc_init(void);
42
 
43
/**
44
    Read millisecond counter.
45
 
46
    @return Number of milliseconds elapsed since last call to mcu_init.
47
*/
48
extern uint32_t soc_get_msecs(void);
49
 
50
 
51
 
52
/*-- CPU ----------------------------------------------------------*/
53
 
54
/**
55
    Enable or disable interrupts globally with EA flag.
56
    Does not affect any other interrupt flag.
57
 
58
    @arg enable 1 to enable interrupts, 0 to disable.
59
*/
60
extern void cpu_enable_interrupts(uint8_t enable);
61
 
62
/*-- Timer 0 ------------------------------------------------------*/
63
 
64
/**
65
    Initialize Timer 0.
66
    This function does not start the timer, only:
67
        -# Loads the T0ARL flag.
68
        -# Clears the T0IRQ flag.
69
        -# Loads the reload register.
70
 
71
    @arg reload Value for reload register, or 0xffff to not use reload mode.
72
*/
73
extern void timer0_init(uint16_t reload);
74
 
75
/**
76
    Start or stop Timer 0 by setting flag T0CEN.
77
 
78
    @arg enable 1 to start the timer, 0 to stop it.
79
*/
80
extern void timer0_enable(uint8_t enable);
81
 
82
 
83
/**
84
    Read value of Timer 0 counter register.
85
    Will make sure the value read is consistent.
86
 
87
    @return Value of Timer 0 counter register.
88
*/
89
extern uint16_t timer0_counter(void);
90
 
91
/**
92
    Enable or disable Timer 0 interrupt.
93
    Does not affect global EA flag.
94
 
95
    @arg enable 1 to enable interrupt, 0 to disable.
96
*/
97
extern void timer0_enable_irq(uint8_t enable);
98
 
99
 
100
/*-- Interrupt function prototypes --------------------------------*/
101
 
102
/*
103
    NOTE:
104
    SDCC requires that the prototype of all irq functions be present in the
105
    file that contains the main function.
106
*/
107
 
108
/**
109
    Interrupt response function for IRQ1 (Timer 0).
110
*/
111
void timer0_isr(void) __interrupt(1);
112
 
113
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.