first submission
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : main.c
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2021/08/08
|
||||
* Description : Main program body.
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* @Note
|
||||
* Composite Keyboard and Mouse Example:
|
||||
* This example uses PA4-PA7 and PB12-PB15 to simulate mouse movement and keyboard
|
||||
* key pressing respectively, active low. At the same time, it also uses USART2
|
||||
* to receive data sent from the host to simulate keyboard key pressing and releasing.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "usb_lib.h"
|
||||
#include "usb_desc.h"
|
||||
#include "usb_pwr.h"
|
||||
#include "usb_prop.h"
|
||||
#include "usbd_composite_km.h"
|
||||
/* Global define */
|
||||
|
||||
/* Global Variable */
|
||||
|
||||
/*********************************************************************
|
||||
* @fn main
|
||||
*
|
||||
* @brief Main program.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
Delay_Init();
|
||||
USART_Printf_Init( 115200 );
|
||||
printf("SystemClk:%d\r\n",SystemCoreClock);
|
||||
printf("USBD Keyboard&Mouse Demo\r\n");
|
||||
|
||||
/* Initialize USART2 for receiving the specified keyboard data */
|
||||
USART2_Init( 115200 );
|
||||
printf( "USART2 Init OK!\r\n" );
|
||||
|
||||
/* Initialize GPIO for keyboard scan */
|
||||
KB_Scan_Init( );
|
||||
KB_Sleep_Wakeup_Cfg( );
|
||||
printf( "KB Scan Init OK!\r\n" );
|
||||
|
||||
/* Initialize GPIO for mouse scan */
|
||||
MS_Scan_Init( );
|
||||
MS_Sleep_Wakeup_Cfg( );
|
||||
printf( "MS Scan Init OK!\r\n" );
|
||||
|
||||
/* Initialize timer for Keyboard and mouse scan timing */
|
||||
TIM3_Init( 1, 7199 );
|
||||
printf( "TIM3 Init OK!\r\n" );
|
||||
|
||||
Set_USBConfig();
|
||||
USB_Init();
|
||||
USB_Interrupts_Config();
|
||||
|
||||
while(1)
|
||||
{
|
||||
if( bDeviceState == CONFIGURED )
|
||||
{
|
||||
/* Handle keyboard scan data */
|
||||
KB_Scan_Handle( );
|
||||
|
||||
/* Handle keyboard lighting */
|
||||
KB_LED_Handle( );
|
||||
|
||||
/* Handle mouse scan data */
|
||||
MS_Scan_Handle( );
|
||||
|
||||
/* Handle USART2 receiving data */
|
||||
USART2_Receive_Handle( );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user