PS2(PS2)

Global variable

Global variabletypeAnnotation
Handkeyu16Key value read temporary storage
Comdu8[2]Start command array
Datau8[9]Data storage array
MASKu16[16]Key to cover the array

Macro definition

Macro definitionvalueAnnotation
PS_RCC_DIRCC_APB2Periph_GPIOBData input DI pin clock
PS_RCC_DORCC_APB2Periph_GPIOBThe clock of the data output DO pin
PS_RCC_CSRCC_APB2Periph_GPIOBClock clock selection CS pin
PS_RCC_CLKRCC_APB2Periph_GPIOBClock clock clock
PS_PIN_DIGPIO_Pin_14Data input DI football
PS_PIN_DOGPIO_Pin_15Data output do foot
PS_PIN_CSGPIO_Pin_12CS pin
PS_PIN_CLKGPIO_Pin_13Clock CLK pin
PS_PORT_DIGPIOBGPIO port of di pin
PS_PORT_DOGPIOBGPIO port of Do pin
PS_PORT_CSGPIOBGPIO port of CS pin
PS_PORT_CLKGPIOBGPIO port of CLK pin
DIPBin(14)Data input
DO_HPBout(15)=1High command position
DO_LPBout(15)=0Low command position
CS_HPBout(12)=1CS pulled high
CS_LPBout(12)=0CS pulled low
CLK_HPBout(13)=1Clock high
CLK_LPBout(13)=0Clock low
PSB_*Corresponding key valueThe constant definition of various keys

method

PS2_Init(void)

PS2 receiver module initialization

Return valuetype
nonevoid

PS2_Cmd(u8 CMD)

Send command to the handle

parametertypeAnnotation
CMDu8Order to be sent
Return valuetype
noneonevoid

PS2_RedLight(void)

Determine whether it is a red light mode

Return valuetype
0u8Red light mode
1u8Other modes

PS2_ReadData(void)

Read the handle data

Return valuetype
nonevoid

PS2_DataKey(void)

Read the key value

Return valuetype
Key valueu8

PS2_AnologData(u8 button)

The analog of getting the joystick

parametertypeAnnotation
buttonu8The joystick button to be read
Return valuetype
Simulationu8

PS2_ClearData(void)

Clear data buffer

Return valuetype
nonevoid

PS2_Vibration(u8 motor1, u8 motor2)

Set the handle vibration

parametertypeAnnotation
motor1u8Small vibration motor on the right (0x00 level, other opening)
motor2u8The left large vibration motor (0x40 ~ 0xff opened, the larger the value, the larger the vibration)
Return valuetype
nonevoid

PS2_ShortPoll(void)

Inquiry

Return valuetype
nonevoid

PS2_EnterConfing(void)

Enter the configuration mode

Return valuetype
nonevoid

PS2_TurnOnAnalogMode(void)

Send analog mode settings

Return valuetype
nonevoid

PS2_VibrationMode(void)

Set up vibration mode

Return valuetype
nonevoid

PS2_ExitConfing(void)

Complete and save configuration

Return valuetype
nonevoid

PS2_SetInit(void)

Controller configuration initialization

Return valuetype
nonevoid

PS2_Data_Show(void)

Key value test and output function

Return valuetype
nonevoid