📄 dc550_phonesm.c
字号:
/*****************************************************************************/
/* CONFIDENTIAL */
/* Sigpro Copyright 2003, All rights reserved */
/*****************************************************************************/
/* CLIENT: Telematrix */
/* PROJECT: DC550 Digital Centrex Phone */
/* FILE: dc550_phonesm.c */
/*****************************************************************************/
/* The Phone State Machine receives commands from the Software Controller */
/* and relays them to the current telephone state. */
/*****************************************************************************/
#define __DC550_PHONESM_EXTERN__
#include "dc550_phonesm.h"
#include "dc550_phonesm_infoaudio.h"
#include "dc550_phonesm_infolanguage.h"
#include "dc550_phonesm_infolevels.h"
#include "dc550_phonesm_infonumbers.h"
#include "dc550_phonesm_infoonetouch.h"
#include "dc550_phonesm_infosettings.h"
#include "dc550_phonesm_infodisplay12.h"
#include "dc550_phonesm_idle.h"
#include "dc550_phonesm_init.h"
#include "dc550_phonesm_memory.h"
#include "dc550_phonesm_predial.h"
#include "dc550_phonesm_program.h"
#include "dc550_phonesm_active.h"
#include "dc550_phonesm_contrast.h"
#include "dc550_phonesm_volume.h"
#include "dc550_phonesm_display12.h"
#include "dc550_i2cdriver.h"
#include "dc550_usartdriver.h"
/******************************************************************************
* GLOBAL VARIABLES
*****************************************************************************/
PHONESM_STATE_E phonesm_currentstate;
/******************************************************************************
* FUNCTION: void phonesm_init(void)
******************************************************************************
* DESCRIPTION:
* This function is called to initialize the Phone State Machine.
*****************************************************************************/
void phonesm_init(void) {
phonesm_init_info();
phonesm_idle_init();
phonesm_init_init();
phonesm_init_hwstates();
phonesm_memory_init();
phonesm_predial_init();
phonesm_program_init();
phonesm_volume_init();
phonesm_display12_init();
phonesm_currentstate = PHONESM_STATE_IDLE;
phonesm_activate_state(PHONESM_STATE_INIT);
}
/******************************************************************************
* FUNCTION: void phonesm_init_info(void)
******************************************************************************
* DESCRIPTION:
* This function sets or resets all of the data for the Phone State Machine.
*****************************************************************************/
void phonesm_init_info(void) {
phonesm_infoaudio_init();
phonesm_infolanguage_init();
phonesm_infolevels_init();
phonesm_infonumbers_init();
phonesm_infoonetouch_init();
phonesm_infosettings_init();
phonesm_infodisplay12_init();
if(eeprom_GetVersion() != EEPROM_VERSION_CURRENT)
eeprom_SetVersion(EEPROM_VERSION_CURRENT);
}
/******************************************************************************
* FUNCTION: void phonesm_init_hwstates(void)
******************************************************************************
* DESCRIPTION:
* This function sets or resets all of the hardware-related states for the
* Phone State Machine.
*****************************************************************************/
void phonesm_init_hwstates(void) {
phonesm_active_init();
phonesm_contrast_init();
}
/******************************************************************************
* FUNCTION: void phonesm_exec_hookswitch(BOOL updown)
******************************************************************************
* DESCRIPTION:
* This function is called when the hookswitch changes state. It delegates
* to the current Phone SM state.
*****************************************************************************/
void phonesm_exec_hookswitch(BOOL updown) {
// Declare temporary variable
unsigned int i;
// Repeat until something returns 0
do {
switch(phonesm_currentstate) {
case PHONESM_STATE_IDLE:
i = phonesm_idle_exec_hookswitch(updown);
break;
case PHONESM_STATE_INIT:
i = phonesm_init_exec_hookswitch(updown);
break;
case PHONESM_STATE_ACTIVE:
i = phonesm_active_exec_hookswitch(updown);
break;
case PHONESM_STATE_PROGRAM:
i = phonesm_program_exec_hookswitch(updown);
break;
case PHONESM_STATE_DISPLAY12:
i = phonesm_display12_exec_hookswitch(updown);
break;
case PHONESM_STATE_VOLUME:
i = phonesm_volume_exec_hookswitch(updown);
break;
case PHONESM_STATE_CONTRAST:
i = phonesm_contrast_exec_hookswitch(updown);
break;
case PHONESM_STATE_MEMORY:
i = phonesm_memory_exec_hookswitch(updown);
break;
case PHONESM_STATE_PREDIAL:
i = phonesm_predial_exec_hookswitch(updown);
break;
};
} while(i);
}
/******************************************************************************
* FUNCTION: void phonesm_exec_keypress(unsigned int key, unsigned int updown)
******************************************************************************
* DESCRIPTION:
* This function is called when a key is pressed or unpressed. It delegates
* to the current Phone SM state.
*****************************************************************************/
void phonesm_exec_keypress(unsigned int key, BOOL updown) {
// Declare temporary variable
unsigned int i;
// Repeat until something returns 0
do {
switch(phonesm_currentstate) {
case PHONESM_STATE_IDLE:
i = phonesm_idle_exec_keypress(key, updown);
break;
case PHONESM_STATE_INIT:
i = phonesm_init_exec_keypress(key, updown);
break;
case PHONESM_STATE_ACTIVE:
i = phonesm_active_exec_keypress(key, updown);
break;
case PHONESM_STATE_PROGRAM:
i = phonesm_program_exec_keypress(key, updown);
break;
case PHONESM_STATE_DISPLAY12:
i = phonesm_display12_exec_keypress(key, updown);
break;
case PHONESM_STATE_VOLUME:
i = phonesm_volume_exec_keypress(key, updown);
break;
case PHONESM_STATE_CONTRAST:
i = phonesm_contrast_exec_keypress(key, updown);
break;
case PHONESM_STATE_MEMORY:
i = phonesm_memory_exec_keypress(key, updown);
break;
case PHONESM_STATE_PREDIAL:
i = phonesm_predial_exec_keypress(key, updown);
break;
};
} while(i);
}
/******************************************************************************
* FUNCTION: void phonesm_exec_modemcommand(DC550MDCMessage command)
******************************************************************************
* DESCRIPTION:
* This function is called when a modem command is received. It delegates
* to the current Phone SM state.
*****************************************************************************/
void phonesm_exec_modemcommand(DC550MDCMessage command) {
// Declare temporary variable
unsigned int i;
// PKW: dc550_printf("Message: %d\r\n", command);
// Repeat until something returns 0
do {
switch(phonesm_currentstate) {
case PHONESM_STATE_IDLE:
i = phonesm_idle_exec_modemcommand(command);
break;
case PHONESM_STATE_INIT:
i = phonesm_init_exec_modemcommand(command);
break;
case PHONESM_STATE_ACTIVE:
i = phonesm_active_exec_modemcommand(command);
break;
case PHONESM_STATE_PROGRAM:
i = phonesm_program_exec_modemcommand(command);
break;
case PHONESM_STATE_DISPLAY12:
i = phonesm_display12_exec_modemcommand(command);
break;
case PHONESM_STATE_VOLUME:
i = phonesm_volume_exec_modemcommand(command);
break;
case PHONESM_STATE_CONTRAST:
i = phonesm_contrast_exec_modemcommand(command);
break;
case PHONESM_STATE_MEMORY:
i = phonesm_memory_exec_modemcommand(command);
break;
case PHONESM_STATE_PREDIAL:
i = phonesm_predial_exec_modemcommand(command);
break;
};
} while(i);
}
/******************************************************************************
* FUNCTION: void phonesm_exec_periodic(void)
******************************************************************************
* DESCRIPTION:
* This function is called periodically (i.e. ten times per second). It
* delegates to the periodic(.) function in the current Phone SM state, which
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -