Skip to content

Commit

Permalink
Rename types.h -> ch554_platform.h
Browse files Browse the repository at this point in the history
  • Loading branch information
rikka0w0 committed Jan 12, 2018
1 parent 3bacefe commit 917a5d4
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Delay.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
看门狗初始化
*******************************************************************************/

#include "types.h"
#include "Delay.H"
#include "ch554_platform.h"


/*******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Delay.H
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
3 changes: 1 addition & 2 deletions ch554_conf.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 3 additions & 1 deletion types.h → ch554_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@




#define GPIO1 0x90
#define GPIO2 0xA0
#define GPIO3 0xB0



Expand Down
2 changes: 1 addition & 1 deletion eeprom.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "types.h"
#include "ch554_platform.h"
#include "i2c.h"

// For 24LC512, A0=0, A1=0, A2=0, WP=Floating
Expand Down
2 changes: 1 addition & 1 deletion eeprom.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion i2c.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "types.h"
#include "i2c.h"
#include "ch554_platform.h"

xdata uint8_t I2C_Buf;

Expand Down
2 changes: 1 addition & 1 deletion i2c.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __I2C_H
#define __I2C_H

#include "types.h"
#include "ch554_platform.h"

extern xdata uint8_t I2C_Buf;

Expand Down
9 changes: 4 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "types.h"

#include "Delay.H"
#include "usb_endp.h"
#include "usb_hid_keyboard.h"

#include <stdio.h>
#include "ch554_platform.h"

uint8_t keyState, kbdModifier, kbdKey;

Expand All @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion usb_bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------*/
Expand Down
4 changes: 1 addition & 3 deletions usb_bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion usb_desc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "usb_desc.h"
#include "types.h"

#include "ch554_platform.h"

// Device Descriptor
code const uint8_t DevDesc[] = {
Expand Down
2 changes: 1 addition & 1 deletion usb_desc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __USB_DESC_H
#define __USB_DESC_H

#include "types.h"
#include "ch554_platform.h"

#define USB_INTERFACES 3

Expand Down
3 changes: 2 additions & 1 deletion usb_endp.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion usb_endp.h
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
2 changes: 1 addition & 1 deletion usb_ep0.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "types.h"
#include "usb_desc.h"
#include "usb_endp.h"
#include <string.h> // For memcpy()

#include "ch554_platform.h"
#include "usb_bot.h"

// Used in SET_FEATURE and CLEAR_FEATURE
Expand Down
2 changes: 1 addition & 1 deletion usb_hid_desc.c
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 2 additions & 0 deletions usb_hid_keyboard.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion usb_hid_keyboard.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion usb_it.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "types.h"
#include "ch554_platform.h"
#include "usb_desc.h"
#include "usb_endp.h"

Expand Down
2 changes: 1 addition & 1 deletion usb_mal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion usb_mal.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __USB_MAL_H
#define __USB_MAL_H

#include "types.h"
#include "ch554_platform.h"

#define MAL_MAX_LUN 0

Expand Down
9 changes: 4 additions & 5 deletions usb_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion usb_scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define __USB_SCSI_H

/* Includes ------------------------------------------------------------------*/
#include "types.h"
#include "ch554_platform.h"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion usb_string_desc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ch554_platform.h"
#include "usb_desc.h"
#include "types.h"

// Language Descriptor
code const uint8_t LangDesc[] = {
Expand Down

0 comments on commit 917a5d4

Please sign in to comment.