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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_STM32F103_Primer_GCC/] [ST_Code/] [circle.h] - Blame information for rev 582

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 582 jeremybenn
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
2
/**
3
*
4
* @file     circle.h
5
* @brief    General header for the CircleOS project.
6
* @author   FL
7
* @date     07/2007
8
* @version  1.5
9
*
10
* It contains the list of the utilities functions organized by sections
11
* (MEMS, LCD, POINTER, ...)
12
*
13
* @date     10/2007
14
* @version  1.5 types of OutX_F64 and OutX_F256 changed to u32 (same for Y and Z)
15
**/
16
/******************************************************************************/
17
 
18
#include "scheduler.h"
19
 
20
/* Define to prevent recursive inclusion -------------------------------------*/
21
#ifndef __CIRCLE_H
22
#define __CIRCLE_H
23
 
24
//-------------------------------- General -------------------------------------
25
/* Defines  ------------------------------------------------------------------*/
26
#define VDD_VOLTAGE_MV  3300 //Voltage (mV) of the STM32
27
#define FA_TABLE        0x8006000
28
#define TIM2            ((TIM_TypeDef *) TIM2_BASE)
29
#define CIRCLEOS_RAM_BASE 0x20004000
30
 
31
/* Variables  ----------------------------------------------------------------*/
32
extern GPIO_InitTypeDef GPIO_InitStructure;
33
 
34
/* Utilities -----------------------------------------------------------------*/
35
void UTIL_uint2str( char *ptr , u32 X, u16 digit, int fillwithzero );
36
void UTIL_int2str( char *ptr , s32 X, u16 digit, int fillwithzero );
37
u16  UTIL_ReadBackupRegister( u16 BKP_DR );
38
void UTIL_WriteBackupRegister( u16 BKP_DR, u16 Data );
39
u16 UTIL_GetBat( void );
40
u8 UTIL_GetUsb( void );
41
u16 UTIL_GetTemp ( void ) ;
42
void UTIL_SetTempMode ( int mode );
43
//typedef void  (*tHandler)    ( void );
44
void UTIL_SetIrqHandler ( int , tHandler );
45
tHandler UTIL_GetIrqHandler ( int  );
46
extern u16  ADC_ConvertedValue[17];
47
 
48
 
49
extern enum eSpeed
50
   {
51
   SPEED_VERY_LOW    = 1,
52
   SPEED_LOW         = 2,
53
   SPEED_MEDIUM      = 3,
54
   SPEED_HIGH        = 4,
55
   SPEED_VERY_HIGH   = 5
56
   } CurrentSpeed;
57
 
58
enum eSchHandler
59
   {
60
   LED_SCHHDL_ID     = 0,
61
   BUTTON_SCHHDL_ID  = 1,
62
   BUZZER_SCHHDL_ID  = 2,
63
   MENU_SCHHDL_ID    = 3,
64
   POINTER_SCHHDL_ID = 4,
65
   LCD_SCHHDL_ID     = 5,
66
   DRAW_SCHHDL_ID    = 6,
67
   RTC_SCHHDL_ID     = 7,
68
 
69
   UNUSED0_SCHHDL_ID = 8,
70
   UNUSED1_SCHHDL_ID = 9,
71
   UNUSED2_SCHHDL_ID = 10,
72
   UNUSED3_SCHHDL_ID = 11,
73
   UNUSED4_SCHHDL_ID = 12,
74
   UNUSED5_SCHHDL_ID = 13,
75
   UNUSED6_SCHHDL_ID = 14,
76
   UNUSED7_SCHHDL_ID = 15
77
   } dummy_var ; //for doxygen
78
 
79
void UTIL_SetSchHandler (  enum eSchHandler , tHandler );
80
tHandler UTIL_GetSchHandler (  enum eSchHandler  );
81
#define NULL_SCHHDL (0)
82
#define LAST_SCHHDL ((tHandler)(-1))
83
 
84
 
85
void UTIL_SetPll( enum eSpeed speed );
86
const char* UTIL_GetVersion( void );
87
enum eSpeed UTIL_GetPll( void );
88
extern RCC_ClocksTypeDef RCC_ClockFreq;
89
extern u8 fTemperatureInFahrenheit;  /*!< 1 : Fahrenheit, 0 : Celcius (default). */
90
 
91
 
92
//---------------------------------   MEMS  ------------------------------------
93
 
94
/* Exported types ------------------------------------------------------------*/
95
typedef enum
96
  {
97
    V12=0,
98
    V3=1,
99
    V6=2,
100
    V9=3
101
} Rotate_H12_V_Match_TypeDef;
102
 
103
typedef struct
104
   {
105
   s16 OutX ;
106
   s16 OutX_F4 ;
107
   s16 OutX_F16 ;
108
   s32 OutX_F64 ;
109
   s32 OutX_F256 ;
110
   s16 OutY ;
111
   s16 OutY_F4 ;
112
   s16 OutY_F16 ;
113
   s32 OutY_F64 ;
114
   s32 OutY_F256 ;
115
   s16 OutZ ;
116
   s16 OutZ_F4 ;
117
   s16 OutZ_F16 ;
118
   s32 OutZ_F64 ;
119
   s32 OutZ_F256 ;
120
   s16 Shocked ;
121
   s16 RELATIVE_X ;
122
   s16 RELATIVE_Y ;
123
   s16 DoubleClick ;
124
   } tMEMS_Info;
125
 
126
extern tMEMS_Info MEMS_Info;
127
 
128
/* Exported functions --------------------------------------------------------*/
129
void MEMS_Init(void);
130
void MEMS_Handler(void);
131
void MEMS_GetPosition(s16 * pX, s16* pY);
132
void MEMS_SetNeutral( void );
133
void MEMS_GetRotation(Rotate_H12_V_Match_TypeDef * H12);
134
tMEMS_Info* MEMS_GetInfo (void);
135
u8 MEMS_ReadID(void);
136
 
137
//----------------------------------   LED -------------------------------------
138
 
139
/* Exported types ------------------------------------------------------------*/
140
enum LED_mode { LED_UNDEF = -1, LED_OFF = 0, LED_ON = 1, LED_BLINKING_LF = 2, LED_BLINKING_HF = 3 };
141
enum LED_id { LED_GREEN = 0, LED_RED = 1};
142
 
143
/* Exported functions --------------------------------------------------------*/
144
void LED_Init (void);
145
void LED_Handler_hw ( enum LED_id id );
146
void LED_Handler ( void );
147
void LED_Set ( enum LED_id id, enum LED_mode mode );
148
 
149
//--------------------------------   ADC  --------------------------------------
150
 
151
/* Exported functions --------------------------------------------------------*/
152
void ADConverter_Init (void);
153
 
154
 
155
//==============================================================================
156
//--------------------------------   SHUTDOWN  ---------------------------------
157
/* Exported functions --------------------------------------------------------*/
158
void SHUTDOWN_Action (void);
159
 
160
//--------------------------------   BUTTON  -----------------------------------
161
/* Exported types ------------------------------------------------------------*/
162
enum BUTTON_mode  { BUTTON_DISABLED  = -1, BUTTON_ONOFF    = 0,
163
                     BUTTON_ONOFF_FORMAIN = 1, BUTTON_WITHCLICK  = 2 };
164
enum BUTTON_state { BUTTON_UNDEF = -1, BUTTON_RELEASED = 0, BUTTON_PUSHED = 1,
165
                     BUTTON_PUSHED_FORMAIN = 2 , BUTTON_CLICK = 3, BUTTON_DBLCLICK = 4 };
166
 
167
/* Exported functions -------------------------------------------------------*/
168
void BUTTON_Init (void);
169
void BUTTON_Handler(void);
170
enum BUTTON_state BUTTON_GetState();
171
void BUTTON_SetMode( enum BUTTON_mode mode);
172
enum BUTTON_mode BUTTON_GetMode ( void ) ;
173
void BUTTON_WaitForRelease();
174
 
175
//--------------------------------   POINTER  ----------------------------------
176
 
177
/* Exported types ------------------------------------------------------------*/
178
enum POINTER_mode  { POINTER_UNDEF  = -1, POINTER_OFF = 0, POINTER_ON = 1, POINTER_MENU  = 2, POINTER_APPLICATION = 3, POINTER_RESTORE_LESS = 4 };
179
enum POINTER_state { POINTER_S_UNDEF  = -1,  POINTER_S_DISABLED = 0, POINTER_S_ENABLED = 1 };
180
 
181
/* Exported defines ----------------------------------------------------------*/
182
#define POINTER_WIDTH 7
183
 
184
typedef struct
185
   {
186
   s16 xPos ;
187
   s16 yPos ;
188
   s16 shift_PosX ;
189
   s16 shift_PosY ;
190
   s16 X_PosMin ;
191
   s16 Y_PosMin ;
192
   s16 X_PosMax ;
193
   s16 Y_PosMax ;
194
   } tPointer_Info;
195
 
196
extern tPointer_Info POINTER_Info ;
197
 
198
/* Exported vars -------------------------------------------------------------*/
199
extern unsigned char *BallPointerBmpSize;
200
extern unsigned char BallPointerBmp [POINTER_WIDTH], *CurrentPointerBmp,*CurrentPointerSize;
201
extern u16 CurrentPointerColor;
202
extern u16 BallColor;
203
extern s16 POINTER_X_PosMin;
204
extern s16 POINTER_Y_PosMin;
205
extern s16 POINTER_X_PosMax;
206
extern s16 POINTER_Y_PosMax;
207
extern unsigned char PointerAreaStore [2*POINTER_WIDTH*POINTER_WIDTH];
208
 
209
/* Exported functions --------------------------------------------------------*/
210
extern void POINTER_Init ( void ) ;
211
void POINTER_Handler(void);
212
u16  POINTER_GetCurrentAngleStart ( void );
213
void POINTER_SetCurrentAngleStart ( u16 );
214
u16  POINTER_GetCurrentSpeedOnAngle ( void );
215
void POINTER_SetCurrentSpeedOnAngle ( u16  newspeed );
216
void POINTER_SetMode( enum POINTER_mode mode);
217
void POINTER_SetCurrentPointer( unsigned char width, unsigned char height, unsigned char *bmp);
218
enum POINTER_state POINTER_GetState(void);
219
void POINTER_Draw (u8 Line, u8 Column, u8 Width, u8 Height, u8 *Bmp);
220
void POINTER_SetRect ( s16 x, s16 y, s16 width, s16 height );  //Restrict the move of the pointer to a rectangle
221
void POINTER_SetRectScreen ( void );   //Remove any space restriction for the pointer moves.
222
void POINTER_Save (u8 Line, u8 Column, u8 Width, u8 Height);
223
void POINTER_Restore (u8 Line, u8 Column, u8 Width, u8 Height);
224
u16  POINTER_GetPos(void);     //Return the poistion of the cursor (x=lower byte, y = upperbyte)
225
void POINTER_SetPos ( u16 x, u16 y );
226
typedef void  (*tAppPtrMgr) ( int , int );
227
void POINTER_SetApplication_Pointer_Mgr(  tAppPtrMgr mgr );
228
tPointer_Info* POINTER_GetInfo ( void );
229
u16 POINTER_GetColor ( void ) ;
230
void POINTER_SetColor ( u16 color );
231
enum POINTER_mode POINTER_GetMode( void );
232
void POINTER_SetCurrentAreaStore ( u8 *ptr );
233
void LCD_SetRotateScreen ( u8 RotateScreen);
234
u8 LCD_GetRotateScreen ();
235
void LCD_SetScreenOrientation (Rotate_H12_V_Match_TypeDef ScreenOrientation);
236
Rotate_H12_V_Match_TypeDef LCD_GetScreenOrientation ();
237
 
238
//----------------------------------   LCD   -----------------------------------
239
 
240
/* Exported defines ----------------------------------------------------------*/
241
//RGB is 16-bit coded as    G2G1G0B4 B3B2B1B0 R4R3R2R1 R0G5G4G3
242
#define RGB_MAKE(xR,xG,xB)    ( ( (xG&0x07)<<13 ) + ( (xG)>>5 )  +      \
243
                                ( ((xB)>>3) << 8 )          +      \
244
                                ( ((xR)>>3) << 3 ) )
245
#define RGB_RED         0x00F8
246
#define RGB_BLACK       0x0000
247
#define RGB_WHITE       0xffff
248
#define RGB_BLUE        0x1F00
249
#define RGB_GREEN       0xE007
250
#define RGB_YELLOW      (RGB_GREEN|RGB_RED)
251
#define RGB_MAGENTA     (RGB_BLUE|RGB_RED)
252
#define RGB_LIGHTBLUE   (RGB_BLUE|RGB_GREEN)
253
#define RGB_ORANGE      (RGB_RED | 0xE001)   //green/2 + red
254
#define RGB_PINK        (RGB_MAGENTA | 0xE001)   //green/2 + magenta
255
 
256
// SCREEN Infos
257
#define SCREEN_WIDTH        128
258
#define SCREEN_HEIGHT        128
259
#define CHIP_SCREEN_WIDTH    132
260
#define CHIP_SCREEN_HEIGHT 132
261
 
262
// Characters Infos
263
#define CHAR_WIDTH            7
264
#define CHAR_HEIGHT           14
265
 
266
// PWM rates.
267
#define BACKLIGHTMIN                0x1000   /*!< Minimal PWM rate.           */
268
#define DEFAULT_CCR_BACKLIGHTSTART  0x8000   /*!< Default PWM rate.           */
269
 
270
/* Exported vars -------------------------------------------------------------*/
271
extern Rotate_H12_V_Match_TypeDef Screen_Orientation;
272
extern int rotate_screen;
273
 
274
/* Exported functions --------------------------------------------------------*/
275
void LCD_Init(void);
276
void LCD_Handler(void);
277
void LCD_SetRect_For_Cmd( s16 x, s16 y, s16 width, s16 height );
278
u16  LCD_GetPixel( u8 x, u8 y );
279
void LCD_DrawPixel( u8 x, u8 y, u16 Pixel );
280
void LCD_SendLCDCmd( u8 Cmd );
281
void LCD_SendLCDData( u8 Data );
282
u32  LCD_ReadLCDData( void );
283
void LCD_FillRect( u16 x, u16 y, u16 width, u16 height, u16 color );
284
void LCD_DrawRect( u16 x, u16 y, u16 width, u16 height, u16 color );
285
void LCD_DisplayChar( u8 x, u8 y, u8 Ascii, u16 TextColor, u16 BGndColor, u16 CharMagniCoeff );
286
void LCD_RectRead( u16 x, u16 y, u16 width, u16 height, u8* bmp );
287
void LCD_SetBackLight (u32 newBacklightStart);
288
u32  LCD_GetBackLight ( void );
289
void LCD_SetBackLightOff( void );
290
void LCD_SetBackLightOn( void );
291
 
292
#include "lcd.h"
293
 
294
//----------------------------------   DRAW   ----------------------------------
295
 
296
/* Exported functions --------------------------------------------------------*/
297
void DRAW_Init(void);
298
void DRAW_Clear(void);
299
void DRAW_Handler(void);
300
void DRAW_SetDefaultColor (void);
301
void DRAW_SetImage(const u16 *imageptr, u8 x, u8 y, u8 width, u8 height);
302
void DRAW_SetImageBW(const u8 *imageptr, u8 x, u8 y, u8 width, u8 height);
303
void DRAW_SetLogoBW(void);
304
void DRAW_DisplayVbat(u8 x, u8 y);
305
void DRAW_DisplayTime(u8 x, u8 y);
306
void DRAW_DisplayTemp(u8 x, u8 y);
307
void DRAW_DisplayString( u8 x, u8 y, const u8 *ptr, u8 len );
308
void DRAW_DisplayStringInverted( u8 x, u8 y, const u8 *ptr, u8 len );
309
u16  DRAW_GetCharMagniCoeff(void);
310
void DRAW_SetCharMagniCoeff(u16 Coeff);
311
u16  DRAW_GetTextColor(void);
312
void DRAW_SetTextColor(u16 Color);
313
u16  DRAW_GetBGndColor(void);
314
void DRAW_SetBGndColor(u16 Color);
315
void DRAW_Batt( void );
316
void DRAW_Line (s16 x1, s16 y1, s16 x2, s16 y2, u16 color );
317
 
318
/* Exported vars -------------------------------------------------------------*/
319
extern int fDisplayTime;
320
 
321
 
322
//--------------------------------   BUZZER  -----------------------------------
323
 
324
/* Exported defines ----------------------------------------------------------*/
325
#define BUZZER_BEEP  BUZZER_SHORTBEEP
326
 
327
/* Exported type def ---------------------------------------------------------*/
328
enum  BUZZER_mode  { BUZZER_UNDEF  = -1, BUZZER_OFF    = 0, BUZZER_ON    = 1,
329
                        BUZZER_SHORTBEEP  = 2, BUZZER_LONGBEEP  = 3, BUZZER_PLAYMUSIC = 4 };
330
 
331
/* Exported type functions ---------------------------------------------------*/
332
void  BUZZER_Init(void);
333
void  BUZZER_Handler(void);
334
void  BUZZER_SetMode( enum BUZZER_mode mode);
335
enum  BUZZER_mode BUZZER_GetMode( void );
336
void  BUZZER_PlayMusic (const u8 *melody );
337
 
338
//---------------------------------   MENU   -----------------------------------
339
 
340
/* Exported defines ----------------------------------------------------------*/
341
#define MENU_MAXITEM 6
342
#define APP_VOID ((tMenuItem *)(-1))
343
#define MAX_APP_MENU_SIZE 10
344
#define MAXAPP  64
345
#define MAX_MENUAPP_SIZE 3
346
#define REMOVE_MENU  0x01
347
#define APP_MENU     0x02
348
 
349
enum  MENU_code  {   MENU_LEAVE  = 0, MENU_CONTINUE = 1, MENU_REFRESH = 2,
350
                        MENU_CHANGE = 3, MENU_CONTINUE_COMMAND = 4};
351
 
352
/* Exported type def ---------------------------------------------------------*/
353
typedef struct
354
   {
355
   const char *Text;
356
   enum MENU_code (*Fct_Init)  ( void );
357
   enum MENU_code (*Fct_Manage)( void );
358
   int fMenuFlag;
359
   } tMenuItem;
360
 
361
typedef struct
362
   {
363
   unsigned fdispTitle : 1;
364
   const char *Title;
365
   int NbItems;
366
   int LgMax;
367
   int XPos, YPos;
368
   int XSize, YSize;
369
   unsigned int SelectedItem;
370
   tMenuItem Items[MENU_MAXITEM];
371
   } tMenu;
372
 
373
/* Exported vars -------------------------------------------------------------*/
374
extern tMenu MainMenu, *CurrentMenu;
375
extern tMenuItem *CurrentCommand;
376
extern int BGndColor_Menu;
377
extern int TextColor_Menu;
378
 
379
/* Exported type functions ---------------------------------------------------*/
380
enum  MENU_code fColor ( void ) ;
381
void  MENU_Set ( tMenu *mptr );
382
void  MENU_Handler ( void ) ;
383
extern enum MENU_code MENU_Quit ( void );
384
void  MENU_Remove ( void ) ;
385
void  MENU_Question ( char *str, int *answer );
386
void  MENU_Print ( char *str );
387
enum  MENU_code MENU_SetLevel_Ini( void );
388
enum  MENU_code MENU_SetLevel_Mgr( u32 *value, u32 value_range [] ) ;
389
void  MENU_ClearCurrentCommand( void );
390
void  MENU_SetLevelTitle(u8* title);
391
void  MENU_SetTextColor ( int TextColor );
392
int   MENU_GetTextColor ( void );
393
void  MENU_SetBGndColor ( int BGndColor );
394
int   MENU_GetBGndColor ( void );
395
extern enum MENU_code fQuit ( void ) ;
396
void MENU_ClearCurrentMenu(void);
397
 
398
//--------------------------------   BACKLIGHT  --------------------------------
399
 
400
/* Exported type functions ---------------------------------------------------*/
401
void  BackLight_Configuration (void);
402
void  ManageBackLight (void);
403
void  BackLight_Change (void);
404
 
405
//--------------------------------   RTC  --------------------------------------
406
 
407
/* Exported type functions ---------------------------------------------------*/
408
void  RTC_Init(void);
409
void  RTC_SetTime (u32 THH, u32 TMM, u32 TSS);
410
void  RTC_GetTime (u32 * THH, u32 * TMM, u32 * TSS);
411
void  RTC_DisplayTime ( void );
412
 
413
//Backup registers
414
#define BKP_SYS1     1
415
#define BKP_SYS2     2
416
#define BKP_SYS3     3
417
#define BKP_SYS4     4
418
#define BKP_SYS5     5
419
#define BKP_SYS6     6
420
#define BKP_USER1    7
421
#define BKP_USER2    8
422
#define BKP_USER3    9
423
#define BKP_USER4    10
424
 
425
#define BKP_PLL      (BKP_SYS2)
426
#define BKP_BKLIGHT  (BKP_SYS3)
427
 
428
//--------------------------------- Application --------------------------------
429
void  (*Application_Pointer_Mgr) ( int sposX, int sposY);
430
 
431
#endif /*__CIRCLE_H */

powered by: WebSVN 2.1.0

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