📄 rs232.c
字号:
/** ###################################################################
** Filename : rs232.C
** Project : rs232
** Processor : MC9S08GT60CFB
** Version : Driver 01.11
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 10/2/2008, 1:07 AM
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2008
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE rs232 */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "RS232DriverEnable.h"
#include "AS1.h"
#include "TI1.h"
#include "Tab_interrupt.h"
#include "Enter_interrupt.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "dispatcher.h"
int i;
/*byte temp_cheragh;
void fcheragh(byte * structure) {
temp_cheragh = structure[0];
//AS1_SendChar(temp_cheragh);
//LED_NegVal();
} */
int VolDown=0;
int VolUp=0;
int chan_up=0;
int chan_down=0;
int power_count=0;
int tab_interrupt_counter=0;
int enter_interrupt_counter=0;
//PTA0
void channel_down(byte * structure){
if(VolDown==0 && VolUp==0 && chan_up==0 && chan_down==0 && power_count==0){
PTAD_PTAD0=1;
chan_down += 4;
}
} //end channel_down
//PTA1
void channel_up(byte * structure){
if(VolDown==0 && VolUp==0 && chan_up==0 && chan_down==0 && power_count==0){
//NOTE: change to PTB3 -> pin 37
PTBD_PTBD3=1;
chan_up += 4;
}
} //end channel_up
//PTA2
//NOTE: add byte * structure as an argument to each function
void volume_down(byte * structure){
if(VolUp==0 && chan_up==0 && chan_down==0 && power_count==0){
PTAD_PTAD2=1;
VolDown++;
}
}
//PTA3
void volume_up(byte * structure){
if(VolDown==0 && chan_up==0 && chan_down==0 && power_count==0){
PTAD_PTAD6=1;
VolUp++;
}
}
//PTAB6
void power(byte * structure){
if(VolDown==0 && VolUp==0 && chan_up==0 && chan_down==0 && power_count==0){
PTBD_PTBD6=1;
power_count +=4;
}
}
void main(void)
{
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
//set the direction of the output pins used in program
PTADD_PTADD0=1;
PTADD_PTADD1=1;
PTADD_PTADD2=1;
PTADD_PTADD3=1;
PTADD_PTADD4=1;
PTADD_PTADD5=1;
PTADD_PTADD6=1;
PTADD_PTADD7=1;
PTBDD_PTBDD0=1;
PTBDD_PTBDD1=1;
PTBDD_PTBDD2=1;
PTBDD_PTBDD3=1;
PTBDD_PTBDD4=1;
PTBDD_PTBDD5=1;
PTBDD_PTBDD6=1;
PTBDD_PTBDD7=1;
/*** End of Processor Expert internal initialization. ***/
TI1_Enable();
//set the enter and tab interrupts to detect rising edges
Tab_interrupt_SetEdge(1);
Enter_interrupt_SetEdge(1);
//enable external interrupt
Tab_interrupt_Enable();
Enter_interrupt_Enable();
//Bit1_SetVal();
//power();
RS232DriverEnable_SetVal();
dispatcher_init();
dispatcher_addFunction("channelDown", &channel_down);
dispatcher_addFunction("channelUp", &channel_up);
dispatcher_addFunction("volumeDown", &volume_down);
dispatcher_addFunction("volumeUp", &volume_up);
dispatcher_addFunction("powerbutton", &power);
/* for (;;) {
for(i=0;i<30000;i++);
//LED_NegVal();
//AS1_SendChar('a');
} */
//LED_NegVal();
for(;;){
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END rs232 */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 3.03 [04.07]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -