-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
262 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
.vscode/settings.json | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/smk_cdc.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __SMK_CDC_H | ||
#define __SMK_CDC_H | ||
|
||
#define CDC_IN_EP 0x84 | ||
#define CDC_OUT_EP 0x03 | ||
#define CDC_INT_EP 0x85 | ||
|
||
void smk_cdc_init(); | ||
|
||
#endif |
14 changes: 14 additions & 0 deletions
14
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/smk_hid.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef __SMK_HID_H | ||
#define __SMK_HID_H | ||
|
||
|
||
#define HID_DESCRIPTOR_LEN 25 | ||
#define HID_KEYBOARD_REPORT_DESC_SIZE 63 | ||
|
||
#define HID_INT_EP 0x81 | ||
#define HID_INT_EP_SIZE 8 | ||
#define HID_INT_EP_INTERVAL 10 | ||
|
||
void smk_hid_usb_init(); | ||
|
||
#endif |
7 changes: 7 additions & 0 deletions
7
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/smk_keyscan.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef __SMK_KEYSCAN_H | ||
#define __SMK_KEYSCAN_H | ||
|
||
|
||
|
||
|
||
#endif |
15 changes: 15 additions & 0 deletions
15
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/smk_msc.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef __SMK_MSC_H | ||
#define __SMK_MSC_H | ||
|
||
#include "hal_usb.h" | ||
#include "usbd_core.h" | ||
#include "usbd_msc.h" | ||
|
||
#define MSC_IN_EP 0x86 | ||
#define MSC_OUT_EP 0x07 | ||
|
||
void usbd_msc_get_cap(uint8_t lun, uint32_t *block_num, uint16_t *block_size); | ||
int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length); | ||
int usbd_msc_sector_write(uint32_t sector, uint8_t *buffer, uint32_t length); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/smk_cdc.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "smk_cdc.h" | ||
#include "usbd_cdc.h" | ||
#include "usbd_core.h" | ||
#include "uart_interface.h" | ||
#include "hal_usb.h" | ||
#include "stdint.h" | ||
|
||
extern struct device *usb_fs; | ||
extern struct usbd_interface_cfg usb_cdc; | ||
|
||
void usbd_cdc_acm_bulk_out(uint8_t ep) | ||
{ | ||
usb_dc_receive_to_ringbuffer(usb_fs, &usb_rx_rb, ep); | ||
} | ||
|
||
void usbd_cdc_acm_bulk_in(uint8_t ep) | ||
{ | ||
usb_dc_send_from_ringbuffer(usb_fs, &uart1_rx_rb, ep); | ||
} | ||
void usbd_cdc_acm_set_line_coding(uint32_t baudrate, uint8_t databits, uint8_t parity, uint8_t stopbits) | ||
{ | ||
uart1_config(baudrate, databits, parity, stopbits); | ||
} | ||
|
||
void usbd_cdc_acm_set_dtr(bool dtr) | ||
{ | ||
dtr_pin_set(dtr); | ||
} | ||
|
||
void usbd_cdc_acm_set_rts(bool rts) | ||
{ | ||
rts_pin_set(rts); | ||
} | ||
|
||
usbd_class_t cdc_class; | ||
|
||
usbd_interface_t cdc_cmd_intf; | ||
usbd_interface_t cdc_data_intf; | ||
|
||
usbd_endpoint_t cdc_out_ep = { | ||
.ep_addr = CDC_OUT_EP, | ||
.ep_cb = usbd_cdc_acm_bulk_out | ||
}; | ||
|
||
usbd_endpoint_t cdc_in_ep = { | ||
.ep_addr = CDC_IN_EP, | ||
.ep_cb = usbd_cdc_acm_bulk_in | ||
}; | ||
|
||
void smk_cdc_init() | ||
{ | ||
uart_ringbuffer_init(); | ||
uart1_init(); | ||
uart1_dtr_init(); | ||
uart1_rts_init(); | ||
|
||
usbd_cdc_add_acm_interface(&cdc_class, &cdc_cmd_intf); | ||
usbd_cdc_add_acm_interface(&cdc_class, &cdc_data_intf); | ||
usbd_interface_add_endpoint(&cdc_data_intf, &cdc_out_ep); | ||
usbd_interface_add_endpoint(&cdc_data_intf, &cdc_in_ep); | ||
} |
66 changes: 66 additions & 0 deletions
66
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/smk_hid.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "smk_hid.h" | ||
#include "smk_keyscan.h" | ||
#include "hal_usb.h" | ||
#include "usbd_core.h" | ||
#include "usbd_hid.h" | ||
|
||
static const uint8_t hid_keyboard_report_desc[HID_KEYBOARD_REPORT_DESC_SIZE] = { | ||
0x05, 0x01, // USAGE_PAGE (Generic Desktop) | ||
0x09, 0x06, // USAGE (Keyboard) | ||
0xa1, 0x01, // COLLECTION (Application) | ||
0x05, 0x07, // USAGE_PAGE (Keyboard) | ||
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) | ||
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) | ||
0x15, 0x00, // LOGICAL_MINIMUM (0) | ||
0x25, 0x01, // LOGICAL_MAXIMUM (1) | ||
0x75, 0x01, // REPORT_SIZE (1) | ||
0x95, 0x08, // REPORT_COUNT (8) | ||
0x81, 0x02, // INPUT (Data,Var,Abs) | ||
0x95, 0x01, // REPORT_COUNT (1) | ||
0x75, 0x08, // REPORT_SIZE (8) | ||
0x81, 0x03, // INPUT (Cnst,Var,Abs) | ||
0x95, 0x05, // REPORT_COUNT (5) | ||
0x75, 0x01, // REPORT_SIZE (1) | ||
0x05, 0x08, // USAGE_PAGE (LEDs) | ||
0x19, 0x01, // USAGE_MINIMUM (Num Lock) | ||
0x29, 0x05, // USAGE_MAXIMUM (Kana) | ||
0x91, 0x02, // OUTPUT (Data,Var,Abs) | ||
0x95, 0x01, // REPORT_COUNT (1) | ||
0x75, 0x03, // REPORT_SIZE (3) | ||
0x91, 0x03, // OUTPUT (Cnst,Var,Abs) | ||
0x95, 0x06, // REPORT_COUNT (6) | ||
0x75, 0x08, // REPORT_SIZE (8) | ||
0x15, 0x00, // LOGICAL_MINIMUM (0) | ||
0x25, 0xFF, // LOGICAL_MAXIMUM (255) | ||
0x05, 0x07, // USAGE_PAGE (Keyboard) | ||
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) | ||
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) | ||
0x81, 0x00, // INPUT (Data,Ary,Abs) | ||
0xc0 // END_COLLECTION | ||
}; | ||
|
||
extern struct device *usb_fs; | ||
|
||
static usbd_class_t hid_class; | ||
static usbd_interface_t hid_intf; | ||
|
||
void usbd_hid_int_callback(uint8_t ep) | ||
{ | ||
uint8_t sendbuffer[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //A | ||
usbd_ep_write(HID_INT_EP, sendbuffer, 8, NULL); | ||
//MSG("A\r\n"); | ||
} | ||
|
||
static usbd_endpoint_t hid_in_ep = { | ||
.ep_cb = usbd_hid_int_callback, | ||
.ep_addr = 0x81 | ||
}; | ||
|
||
extern struct device *usb_dc_init(void); | ||
|
||
void smk_hid_usb_init() | ||
{ | ||
usbd_hid_add_interface(&hid_class, &hid_intf); | ||
usbd_interface_add_endpoint(&hid_intf, &hid_in_ep); | ||
usbd_hid_report_descriptor_register(0, hid_keyboard_report_desc, HID_KEYBOARD_REPORT_DESC_SIZE); | ||
} |
Empty file.
Empty file.
Oops, something went wrong.