Skip to content

Commit a28305e

Browse files
committed
USB init moved to separate file
1 parent 8f39aa4 commit a28305e

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

firmware/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ vpath %.s $(SRC_DIR)
4848

4949
STARTUP=startup_stm32f10x_hd.s
5050
USB_SRCS=hw_config.c stm32_it.c usb_prop.c usb_desc.c usb_istr.c usb_pwr.c \
51-
usb_endp.c
51+
usb_endp.c usb.c
5252

5353

5454
SRCS=main.c system_stm32f10x.c syscalls.c fsmc_nand.c chip_db.c led.c uart.c \

firmware/main.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
/* SPL */
1111
#include <stm32f10x.h>
1212
/* USB */
13-
#include <usb_lib.h>
14-
#include <usb_pwr.h>
15-
#include "hw_config.h"
13+
#include "usb.h"
1614
#include "cdc.h"
1715
/* LED */
1816
#include "led.h"
@@ -190,15 +188,6 @@ static np_comm_cb_t *np_comm_cb;
190188

191189
uint8_t np_packet_send_buf[NP_PACKET_BUF_SIZE];
192190

193-
static void np_usb_init()
194-
{
195-
Set_System();
196-
Set_USBClock();
197-
USB_Interrupts_Config();
198-
USB_Init();
199-
while (!USB_IsDeviceConfigured());
200-
}
201-
202191
static int np_send_ok_status()
203192
{
204193
np_resp_t status = { NP_RESP_STATUS, NP_STATUS_OK };
@@ -813,7 +802,7 @@ int main()
813802
printf("done.\r\n");
814803

815804
printf("USB init...");
816-
np_usb_init();
805+
usb_init();
817806
printf("done.\r\n");
818807

819808
printf("CDC init...");

firmware/usb.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Copyright (C) 2017 Bogdan Bogush <[email protected]>
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#include "hw_config.h"
7+
#include <usb_lib.h>
8+
#include <usb_pwr.h>
9+
10+
void usb_init()
11+
{
12+
Set_System();
13+
Set_USBClock();
14+
USB_Interrupts_Config();
15+
USB_Init();
16+
while (!USB_IsDeviceConfigured());
17+
}

firmware/usb.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Copyright (C) 2017 Bogdan Bogush <[email protected]>
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#ifndef _USB_H_
7+
#define _USB_H_
8+
9+
void usb_init();
10+
11+
#endif

0 commit comments

Comments
 (0)