From 917a5d4046ed158395c862778f2e9f52aabe0a13 Mon Sep 17 00:00:00 2001 From: rikka0w0 <929513338@qq.com> Date: Fri, 12 Jan 2018 17:39:02 +0800 Subject: [PATCH] Rename types.h -> ch554_platform.h --- Delay.C | 2 +- Delay.H | 2 +- ch554_conf.c | 3 +-- types.h => ch554_platform.h | 4 +++- eeprom.c | 2 +- eeprom.h | 2 +- i2c.c | 2 +- i2c.h | 2 +- main.c | 9 ++++----- usb_bot.c | 3 ++- usb_bot.h | 4 +--- usb_desc.c | 3 ++- usb_desc.h | 2 +- usb_endp.c | 3 ++- usb_endp.h | 2 +- usb_ep0.c | 2 +- usb_hid_desc.c | 2 +- usb_hid_keyboard.c | 2 ++ usb_hid_keyboard.h | 4 +++- usb_it.c | 2 +- usb_mal.c | 2 +- usb_mal.h | 2 +- usb_scsi.c | 9 ++++----- usb_scsi.h | 2 +- usb_string_desc.c | 2 +- 25 files changed, 39 insertions(+), 35 deletions(-) rename types.h => ch554_platform.h (98%) diff --git a/Delay.C b/Delay.C index 789e6fb..00cc7f0 100644 --- a/Delay.C +++ b/Delay.C @@ -10,8 +10,8 @@ ¿´ÃŹ·³õʼ»¯ *******************************************************************************/ -#include "types.h" #include "Delay.H" +#include "ch554_platform.h" /******************************************************************************* diff --git a/Delay.H b/Delay.H index 10e91dc..2663b4c 100644 --- a/Delay.H +++ b/Delay.H @@ -1,7 +1,7 @@ #ifndef __DELAY_H__ #define __DELAY_H__ -#include "types.h" +#include "ch554_platform.h" void mDelayuS(uint16_t n ); void mDelaymS(uint16_t n ); diff --git a/ch554_conf.c b/ch554_conf.c index 2078317..7807197 100644 --- a/ch554_conf.c +++ b/ch554_conf.c @@ -1,6 +1,5 @@ #include "Delay.H" -#include "types.h" -#include "ch554_conf.H" +#include "ch554_platform.h" #include "usb_desc.h" #include "usb_endp.h" diff --git a/types.h b/ch554_platform.h similarity index 98% rename from types.h rename to ch554_platform.h index 2c458ed..20030a5 100644 --- a/types.h +++ b/ch554_platform.h @@ -139,7 +139,9 @@ - +#define GPIO1 0x90 +#define GPIO2 0xA0 +#define GPIO3 0xB0 diff --git a/eeprom.c b/eeprom.c index 15ce07e..5b27494 100644 --- a/eeprom.c +++ b/eeprom.c @@ -1,4 +1,4 @@ -#include "types.h" +#include "ch554_platform.h" #include "i2c.h" // For 24LC512, A0=0, A1=0, A2=0, WP=Floating diff --git a/eeprom.h b/eeprom.h index 58f8dc1..e8dd6f8 100644 --- a/eeprom.h +++ b/eeprom.h @@ -1,7 +1,7 @@ #ifndef __I2C_EEPROM_H #define __I2C_EEPROM_H -#include "types.h" +#include "ch554_platform.h" #define EEPROM_SIZE 65536 //Capacity 64KiB #define EEPROM_SECTORSIZE 512 //Sector Size 512B diff --git a/i2c.c b/i2c.c index 0ac5cf4..408898b 100644 --- a/i2c.c +++ b/i2c.c @@ -1,5 +1,5 @@ -#include "types.h" #include "i2c.h" +#include "ch554_platform.h" xdata uint8_t I2C_Buf; diff --git a/i2c.h b/i2c.h index c2b3590..bb3c2e5 100644 --- a/i2c.h +++ b/i2c.h @@ -1,7 +1,7 @@ #ifndef __I2C_H #define __I2C_H -#include "types.h" +#include "ch554_platform.h" extern xdata uint8_t I2C_Buf; diff --git a/main.c b/main.c index ae0cd99..380519a 100644 --- a/main.c +++ b/main.c @@ -1,10 +1,9 @@ -#include "types.h" - #include "Delay.H" #include "usb_endp.h" #include "usb_hid_keyboard.h" #include +#include "ch554_platform.h" uint8_t keyState, kbdModifier, kbdKey; @@ -17,10 +16,10 @@ void main(void) { while(1) { while(keyState == KBD_STATE_IDLE); - keyState = KBD_STATE_KEYDOWN; + keyState = KBD_STATE_KEYDOWN; USB_Keyboard_SendKey(kbdModifier, kbdKey); - while(keyState == KBD_STATE_KEYDOWN); - USB_Keyboard_SendKey(0, 0); + while(keyState == KBD_STATE_KEYDOWN); + USB_Keyboard_SendKey(0, 0); } } diff --git a/usb_bot.c b/usb_bot.c index 8dbc31a..6246319 100644 --- a/usb_bot.c +++ b/usb_bot.c @@ -29,10 +29,11 @@ /* Includes ------------------------------------------------------------------*/ #include "usb_scsi.h" #include "usb_bot.h" + +#include "ch554_platform.h" #include "usb_mal.h" #include "usb_endp.h" -#include "types.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ diff --git a/usb_bot.h b/usb_bot.h index 2ecf21f..db348e6 100644 --- a/usb_bot.h +++ b/usb_bot.h @@ -31,9 +31,7 @@ #define __USB_BOT_H /* Includes ------------------------------------------------------------------*/ -#include "types.h" - -// BOT_USB Config +#include "ch554_platform.h" #include "usb_endp.h" #define BOT_Rx_Buf EP3_RX_BUF #define BOT_Tx_Buf EP3_TX_BUF diff --git a/usb_desc.c b/usb_desc.c index 374626f..c62da32 100644 --- a/usb_desc.c +++ b/usb_desc.c @@ -1,5 +1,6 @@ #include "usb_desc.h" -#include "types.h" + +#include "ch554_platform.h" // Device Descriptor code const uint8_t DevDesc[] = { diff --git a/usb_desc.h b/usb_desc.h index f4ae53d..6ceba4c 100644 --- a/usb_desc.h +++ b/usb_desc.h @@ -1,7 +1,7 @@ #ifndef __USB_DESC_H #define __USB_DESC_H -#include "types.h" +#include "ch554_platform.h" #define USB_INTERFACES 3 diff --git a/usb_endp.c b/usb_endp.c index f29a6f9..45011b5 100644 --- a/usb_endp.c +++ b/usb_endp.c @@ -1,5 +1,6 @@ -#include "types.h" #include "usb_endp.h" + +#include "ch554_platform.h" #include "usb_hid_keyboard.h" #define MAX_PACKET_SIZE 64 diff --git a/usb_endp.h b/usb_endp.h index 5b6e0fb..c4d9e23 100644 --- a/usb_endp.h +++ b/usb_endp.h @@ -1,7 +1,7 @@ #ifndef __USB_ENDP_H #define __USB_ENDP_H -#include "types.h" +#include "ch554_platform.h" uint8_t USB_EP_HALT_SET(uint8_t ep); uint8_t USB_EP_HALT_CLEAR(uint8_t ep); diff --git a/usb_ep0.c b/usb_ep0.c index a960ea9..72ec965 100644 --- a/usb_ep0.c +++ b/usb_ep0.c @@ -1,8 +1,8 @@ -#include "types.h" #include "usb_desc.h" #include "usb_endp.h" #include // For memcpy() +#include "ch554_platform.h" #include "usb_bot.h" // Used in SET_FEATURE and CLEAR_FEATURE diff --git a/usb_hid_desc.c b/usb_hid_desc.c index 79b2355..cc550f1 100644 --- a/usb_hid_desc.c +++ b/usb_hid_desc.c @@ -1,5 +1,5 @@ +#include "ch554_platform.h" #include "usb_desc.h" -#include "types.h" code const uint8_t KeyRepDesc[] = { 0x05,0x01,0x09,0x06,0xA1,0x01,0x05,0x07, diff --git a/usb_hid_keyboard.c b/usb_hid_keyboard.c index 83ddc40..e84bd2c 100644 --- a/usb_hid_keyboard.c +++ b/usb_hid_keyboard.c @@ -1,6 +1,8 @@ #include "usb_hid_keyboard.h" #include "usb_endp.h" +// Send a USB HID keyboard report to host +// For detailed format, check this out: https://docs.mbed.com/docs/ble-hid/en/latest/api/md_doc_HID.html void USB_Keyboard_SendKey(uint8_t modifier, uint8_t key) { KBD_Tx_Buf[0] = modifier; KBD_Tx_Buf[1] = 0; // reserved diff --git a/usb_hid_keyboard.h b/usb_hid_keyboard.h index 0bd1fc0..2f41121 100644 --- a/usb_hid_keyboard.h +++ b/usb_hid_keyboard.h @@ -1,11 +1,12 @@ #ifndef __USB_HID_KEYBOARD_H #define __USB_HID_KEYBOARD_H -#include "types.h" +#include "ch554_platform.h" #define KBD_Tx_Buf Ep1Buffer #define KBD_Tx_Enable() {UEP1_CTRL = UEP1_CTRL & ~ MASK_UEP_T_RES | UEP_T_RES_ACK;} +// Modifiers #define KBD_LCTRL 0x01 #define KBD_LSHIFT 0x02 #define KBD_LALT 0x04 @@ -15,6 +16,7 @@ #define KBD_RALT 0x40 #define KBD_RGUI 0x80 +// Key State #define KBD_STATE_IDLE 0 #define KBD_STATE_KEYDOWN 1 #define KBD_STATE_KEYUP 2 diff --git a/usb_it.c b/usb_it.c index 17311a8..be2a83e 100644 --- a/usb_it.c +++ b/usb_it.c @@ -1,4 +1,4 @@ -#include "types.h" +#include "ch554_platform.h" #include "usb_desc.h" #include "usb_endp.h" diff --git a/usb_mal.c b/usb_mal.c index e607001..9b88231 100644 --- a/usb_mal.c +++ b/usb_mal.c @@ -60,7 +60,7 @@ void LUN_Write (uint8_t lun, uint32_t curAddr) { } } -SBIT(ledEject, 0x90, 0); +SBIT(ledEject, GPIO1, 0); void LUN_Eject (uint8_t lun) { if (lun == 0) { EEPROM_Status = MAL_FAIL; diff --git a/usb_mal.h b/usb_mal.h index 9ce8a99..654f00c 100644 --- a/usb_mal.h +++ b/usb_mal.h @@ -1,7 +1,7 @@ #ifndef __USB_MAL_H #define __USB_MAL_H -#include "types.h" +#include "ch554_platform.h" #define MAL_MAX_LUN 0 diff --git a/usb_scsi.c b/usb_scsi.c index 18dd4cd..545c2ee 100644 --- a/usb_scsi.c +++ b/usb_scsi.c @@ -32,14 +32,13 @@ #include "usb_mal.h" #include "eeprom.h" - +#include "ch554_platform.h" #include "usb_endp.h" -#include "types.h" -SBIT(led, 0x90, 1); +SBIT(ledRW, GPIO1, 1); /* Private typedef -----------------------------------------------------------*/ -#define RW_LED_ON() led=0 -#define RW_LED_OFF() led=1 +#define RW_LED_ON() ledRW=0 +#define RW_LED_OFF() ledRW=1 /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ diff --git a/usb_scsi.h b/usb_scsi.h index 2bc661c..8824828 100644 --- a/usb_scsi.h +++ b/usb_scsi.h @@ -31,7 +31,7 @@ #define __USB_SCSI_H /* Includes ------------------------------------------------------------------*/ -#include "types.h" +#include "ch554_platform.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ diff --git a/usb_string_desc.c b/usb_string_desc.c index a8fa3e0..4556de2 100644 --- a/usb_string_desc.c +++ b/usb_string_desc.c @@ -1,5 +1,5 @@ +#include "ch554_platform.h" #include "usb_desc.h" -#include "types.h" // Language Descriptor code const uint8_t LangDesc[] = {