Subversion Repositories svn.mios32

Rev

Rev 800 | Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
87 tk 1
// $Id: mios32_irq.h 1156 2011-03-27 18:45:18Z tk $
2
/*
121 tk 3
 * This file collects all interrupt priorities and provides prototypes to
4
 * MIOS32_IRQ_* functions
87 tk 5
 *
6
 * ==========================================================================
7
 *
8
 *  Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
9
 *  Licensed for personal non-commercial use only.
10
 *  All other rights reserved.
11
 *
12
 * ==========================================================================
13
 */
14
 
15
#ifndef _MIOS32_IRQ_H
16
#define _MIOS32_IRQ_H
17
 
1156 tk 18
 
19
#ifndef NVIC_PriorityGroup_0
20
// (only defined by STM32 driver, not by LPC driver)
21
#define NVIC_PriorityGroup_0         ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
22
                                                            4 bits for subpriority */
23
#define NVIC_PriorityGroup_1         ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
24
                                                            3 bits for subpriority */
25
#define NVIC_PriorityGroup_2         ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
26
                                                            2 bits for subpriority */
27
#define NVIC_PriorityGroup_3         ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
28
                                                            1 bits for subpriority */
29
#define NVIC_PriorityGroup_4         ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
30
 
31
#endif
32
 
33
 
87 tk 34
// we are using 4 bits for pre-emption priority, and no bits for subpriority
35
// this means: subpriority can always be set to 0, therefore no special 
36
// define is available for thi setting
37
#define MIOS32_IRQ_PRIGROUP    NVIC_PriorityGroup_4
38
 
39
 
40
// than lower the value, than higher the priority!
41
 
42
// note that FreeRTOS allows priority level < 10 for "SysCalls"
43
// means: FreeRTOS tasks can be interrupted by level<10 IRQs
44
 
45
 
115 tk 46
// predefined user timer priorities (-> MIOS32_TIMER)
47
#define MIOS32_IRQ_PRIO_LOW       12  // lower than RTOS
48
#define MIOS32_IRQ_PRIO_MID        8  // higher than RTOS
385 tk 49
#define MIOS32_IRQ_PRIO_HIGH       5  // same like SPI, AIN, etc...
50
#define MIOS32_IRQ_PRIO_HIGHEST    4  // higher than SPI, AIN, etc...
115 tk 51
 
52
 
53
 
385 tk 54
// DMA Channel IRQ used by MIOS32_SPI
55
#define MIOS32_IRQ_SPI_DMA_PRIORITY    MIOS32_IRQ_PRIO_HIGH
87 tk 56
 
57
 
113 tk 58
// DMA Channel IRQ used by MIOS32_I2S, 
59
// period depends on sample buffer size, but usually 1..2 mS
60
// relaxed conditions (since samples are transfered in background)
800 tk 61
#define MIOS32_IRQ_I2S_DMA_PRIORITY     MIOS32_IRQ_PRIO_HIGH
113 tk 62
 
90 tk 63
// DMA Channel IRQ used by MIOS32_AIN, called after 
64
// all ADC channels have been converted
115 tk 65
#define MIOS32_IRQ_AIN_DMA_PRIORITY     MIOS32_IRQ_PRIO_HIGH
90 tk 66
 
67
 
87 tk 68
// IIC IRQs used by MIOS32_IIC, called rarely on IIC accesses
69
// should be very high to overcome peripheral flaws (see header of mios32_iic.c)
70
// estimated requirement for "reaction time": less than 9/400 kHz = 22.5 uS
71
// EV and ER IRQ should have same priority since they are sharing resources
72
#define MIOS32_IRQ_IIC_EV_PRIORITY      2
73
#define MIOS32_IRQ_IIC_ER_PRIORITY      2
74
 
90 tk 75
 
87 tk 76
// UART IRQs used by MIOS32_UART
77
// typically called each 320 mS if full MIDI bandwidth is used
78
// priority should be high to avoid data loss
115 tk 79
#define MIOS32_IRQ_UART_PRIORITY        MIOS32_IRQ_PRIO_HIGHEST
87 tk 80
 
81
 
99 tk 82
// USB provides flow control - this interrupt can run at low priority (but higher than RTOS tasks)
83
// The interrupt is called at least each mS and takes ca. 1 uS to service the SOF (Start of Frame) flag
84
 
115 tk 85
#define MIOS32_IRQ_USB_PRIORITY         MIOS32_IRQ_PRIO_MID
99 tk 86
 
87
 
121 tk 88
 
89
/////////////////////////////////////////////////////////////////////////////
90
// Prototypes
91
/////////////////////////////////////////////////////////////////////////////
92
 
93
extern s32 MIOS32_IRQ_Disable(void);
94
extern s32 MIOS32_IRQ_Enable(void);
95
 
96
 
87 tk 97
#endif /* _MIOS32_IRQ_H */