freescale
来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 267 行
TXT
267 行
#ifndef _TAXI_STATES_H__
#define _TAXI_STATES_H__
/************************************************************
DEFINES
************************************************************/
#define LENGTH_MESSAGE 8
#define LENGTH_3_MESSAGES 24
#define LENGTH_8_MESSAGES 64
/************************************************************
FUNCTION PROTOTYPES
************************************************************/
/**
* Free: Idle state. It shows in the displayes the label
* "FREE" and constantly scans the value of the buttons.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: current_state.
*
* Subfunctions: DisplayMsg().
*
* Return: void
*/
void Free(void);
/**
* Service: Starts charging.
* According to time and distance, it increments
* the value of the total amount to pay by the
* costumer and displays it.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
* accumulator_extras.
* ini_ch_active.
*
* Variables modified: accumulator_trip.
* flag_charge.
* current_state.
*
* Subfunctions: DisplayMsg().
* DisplayNum().
* Delay().
*
* Return: void
*/
void Service(void);
/**
* Pay: Stops charging.
* Displays (toggling) the label " PAY " and the total
* amount to pay.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
* accumulator_trip.
*
* Variables modified: flag_charge.
* current_state.
*
* Subfunctions: DisplayMsg().
* DisplayNum().
* Delay().
*
* Return: void
*/
void Pay(void);
/**
* Extras: Adds one or more extra charges to the extras'
* accumulator. It can also clear this accumulator.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: accumulator_extras.
* arr_display[5]
* current_state.
*
* Subfunctions: DisplayMsg().
* Delay().
*
* Return: void
*/
void Extras(void);
/**
* Fares: Selects the fare type to use as well as the
* initial charge corresponding to that fare.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: fare_active.
* ini_ch_active.
* current_state.
* arr_display[0].
* fare_type.
*
* Subfunctions: DisplayMsg().
* Delay().
*
* Return: void
*/
void Fares(void);
/**
* Clock: Display the time.
* The hour and minute counters are managed in the
* Timer ISR
*
* Parameters: none.
*
* Variables read: pushed_buttons.
* clock_hours.
* clock_minutes.
*
* Variables modified: clock_hours.
* clock_minutes.
* current_state.
*
* Subfunctions: DisplayMsg().
* DisplayNum().
* Delay().
*
* Return: void
*/
void Clock(void);
/**
* Speedometer: Shows the speed at which the car is traveling.
* The speed is calculated as following:
* #of-wheel-turns / time
* It is assumed that the perimeter of the wheel
* is one meter.
* The speedometer has a resolution of 2.4 Km/h,
* this resolution can be improved by increasing
* the _time and re-calculate the _factor.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
* counter_ms.
* counter_pulses.
*
* Variables modified: counter_ms.
* counter_pulses.
* current_state.
*
* Subfunctions: DisplayMsg().
* DisplayNum().
* Delay().
*
* Return: void
*/
void Speedometer(void);
/**
* Pulses: Verifies that the wheel-turn transductor is working
* properly. It counts the number of pulses caused
* by the turn of the wheels and it displays it. It
* can also reset or freeze the counting.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
* counter_pulses.
*
* Variables modified: counter_pulses.
* current_state.
*
* Subfunctions: DisplayNum().
* Delay().
*
* Return: void
*/
void Pulses(void);
/**
* Info: Displays the desired information and the accumulators.
* The information to be displayed is stored in
* INFO_TABLE. It can display 3 messages (8 character
* long each message). It also displays the accumulators
* stored in flash. The accummulators are displayed in
* the following order:
* TOTAL_DISTANCE_TRAVELED
* TOTAL_DISTANCE_IN_SERVICE
* TOTAL_NUMBER_TRAVELS
* TOTAL_NUMBER_INCREMENTS
* TOTAL_INCOME
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: current_state.
*
* Subfunctions: DisplayMsg().
* DisplayNum().
* Delay().
*
* Return: void
*/
void Info(void);
/**
* Program: Changes reference values with new ones, such as:
* fares, initial charges, extra charges, active
* fares, active extra charges, information table.
* All interrupts are disabled while communication
* is in process.
* It waits indefinetly to receive a byte. If
* the byte is never received (there's no connection)
* the taximeter must be restarted.
* After programation is done, the taximeter must be
* restarted. There's an infinite loop (this way
* the RAM data that was overwritten doesn't need to
* be previously backed up.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: accumulator_extras.
* arr_display[5]
* current_state.
*
* Subfunctions: DisplayMsg().
* Delay().
* EraseRow().
* ProgramRange().
* ProgramVerification2().
* RestoreRAMData().
*
* Return: void
*/
void Program (void);
/**
* Off: Add up to accumulator and store in flash the Km
* traveled since the last time it was stored.
* Turns displays off.
* Exit this state with any button pushed.
*
* Parameters: none.
*
* Variables read: pushed_buttons.
*
* Variables modified: current_state.
*
* Subfunctions: DisplayMsg().
*
* Return: void
*/
void Off(void);
#endif // _TAXI_STATES_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?