Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
53 tk 1
; $Id: mios_system.inc 53 2008-01-30 22:52:41Z tk $
1 tk 2
;
3
; MIOS System Routines
4
;
5
; ==========================================================================
6
;
7
;  Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
8
;  Licensed for personal non-commercial use only.
9
;  All other rights reserved.
10
;
11
; ==========================================================================
12
 
13
;; --------------------------------------------------------------------------
14
;;  FUNCTION: MIOS_Reset
15
;;  C_DECLARATION: void MIOS_Reset(void)
16
;;  DESCRIPTION: waits until the Tx MIDI buffer is empty, thereafter resets the OS
17
;;  IN:	  -
18
;;  C_IN:  -
19
;;  OUT:  -
20
;;  C_OUT:  -
21
;;  USES: -
22
;; --------------------------------------------------------------------------
23
MIOS_Reset
24
	;; clear screen
25
	call	MIOS_LCD_Clear
26
 
27
	;; setup default font
28
	TABLE_ADDR MIOS_GLCD_FONT
29
	call	MIOS_GLCD_FontInit
30
 
31
	;; print reboot message
32
	TABLE_ADDR TEXT_MIOS_REBOOT_0
33
	call	MIOS_LCD_PrintString
34
 
35
	;; suspend all IRQ routines expect for the MIDI handler
36
	rcall	MIOS_SystemSuspend
37
 
38
	;; feed the watchdog (last time before reset)
39
	clrwdt
40
 
41
	;; wait until all MIDI bytes have been transmitted
42
	call	MIOS_MIDI_TxBufferFlush
43
 
44
	;; RESET BOX!
45
	reset
46
 
47
	;; secure halt
48
MIOS_Reset_Endless
49
	rgoto	MIOS_Reset_Endless
50
 
51
TEXT_MIOS_REBOOT_0	da 0x1000, "Rebooting MIOS  "
52
 
53
;; --------------------------------------------------------------------------
54
;;  FUNCTION: MIOS_SystemSuspend
55
;;  C_DECLARATION: void MIOS_SystemSuspend(void)
56
;;  DESCRIPTION: suspends all system and user tasks except for the IO MIDI handler
57
;;  IN:	  -
58
;;  C_IN:  -
59
;;  OUT:  -
60
;;  C_OUT:  -
61
;;  USES: FSR1
62
;; --------------------------------------------------------------------------
63
MIOS_SystemSuspend
64
	;; skip DOUT flushing if system already suspended
65
	BRA_IFCLR MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER, ACCESS, MIOS_SystemSuspend_Now
66
	BRA_IFSET MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_ALL, ACCESS, MIOS_SystemSuspend_NoFlush
67
MIOS_SystemSuspend_Now
68
 
69
	;; suspend all IRQ routines expect for the MIDI handler
70
	bsf	MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_ALL
71
	bsf	MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER
72
 
73
	;; flush DOUT and SRM bits
74
	bcf	MIOS_SRIO_LAT_DOUT, MIOS_SRIO_PIN_DOUT
75
 	bcf	MIOS_MF_LAT_DOUT, MIOS_MF_PIN_DOUT
76
	movlw	0x80
77
	movwf	WREG
78
MIOS_SystemSuspend_SRs_Loop
79
        bsf     MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK
80
        bsf     MIOS_MF_LAT_SCLK, MIOS_MF_PIN_SCLK
81
        bcf     MIOS_SRIO_LAT_SCLK, MIOS_SRIO_PIN_SCLK
82
        bcf     MIOS_MF_LAT_SCLK, MIOS_MF_PIN_SCLK
83
	decfsz	WREG, F
84
	rgoto	MIOS_SystemSuspend_SRs_Loop
85
 
86
        bcf	MIOS_SRIO_LAT_RCLK, MIOS_SRIO_PIN_RCLK	; latch disable
87
        bcf	MIOS_MF_LAT_RCLK, MIOS_MF_PIN_RCLK
88
 
89
        bsf	MIOS_SRIO_LAT_RCLK, MIOS_SRIO_PIN_RCLK	; latch enable
90
        bsf	MIOS_MF_LAT_RCLK, MIOS_MF_PIN_RCLK
91
 
92
MIOS_SystemSuspend_NoFlush
93
	return
94
 
95
;; --------------------------------------------------------------------------
96
;;  FUNCTION: MIOS_SystemResume
97
;;  C_DECLARATION: void MIOS_SystemResume(void)
98
;;  DESCRIPTION: resumes all system tasks
99
;;  IN:	  -
100
;;  C_IN:  -
101
;;  OUT:  -
102
;;  C_OUT:  -
103
;;  USES: -
104
;; --------------------------------------------------------------------------
105
MIOS_SystemResume
106
	bcf	MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_ALL
107
	return
108
 
109
;; --------------------------------------------------------------------------
110
;;  FUNCTION: MIOS_UserSuspend
111
;;  C_DECLARATION: void MIOS_UserSuspend(void)
112
;;  DESCRIPTION: suspends all user tasks
113
;;  IN:	  -
114
;;  C_IN:  -
115
;;  OUT:  -
116
;;  C_OUT:  -
117
;;  USES: -
118
;; --------------------------------------------------------------------------
119
MIOS_UserSuspend
120
	;; suspend all IRQ routines expect for the MIDI handler
121
	bsf	MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER
122
	return
123
 
124
;; --------------------------------------------------------------------------
125
;;  FUNCTION: MIOS_UserResume
126
;;  C_DECLARATION: void MIOS_UserResume(void)
127
;;  DESCRIPTION: resumes all user tasks
128
;;  IN:	  -
129
;;  C_IN:  -
130
;;  OUT:  -
131
;;  C_OUT:  -
132
;;  USES: -
133
;; --------------------------------------------------------------------------
134
MIOS_UserResume
135
	bcf	MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER
136
	return