Skip to content

Commit afe12bc

Browse files
committed
Fix IRQ priority issue to give working USB; and some cleanup.
1 parent fb42ec1 commit afe12bc

10 files changed

Lines changed: 185 additions & 164 deletions

File tree

stm/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SRC_C = \
1818
lcd.c \
1919
flash.c \
2020
storage.c \
21+
mma.c \
2122
string0.c \
2223
malloc0.c \
2324
systick.c \
@@ -29,10 +30,10 @@ SRC_S = \
2930
startup_stm32f40xx.s \
3031

3132
PY_O = \
32-
# nlrthumb.o \
33+
nlrthumb.o \
3334
malloc.o \
3435
qstr.o \
35-
# misc.o \
36+
misc.o \
3637
lexer.o \
3738
parse.o \
3839
scope.o \

stm/lib/usb_bsp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) {
106106
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
107107
GPIO_Init(GPIOA, &GPIO_InitStructure);
108108

109-
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_OTG1_FS);
110-
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_OTG1_FS);
109+
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_OTG_FS);
110+
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_OTG_FS);
111111

112112
/* Configure VBUS Pin (or disable VBUS_SENSING_ENABLED) */
113113
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
@@ -123,16 +123,16 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) {
123123

124124
/**
125125
* @brief USB_OTG_BSP_EnableInterrupt
126-
* Enabele USB Global interrupt
126+
* Enable USB Global interrupt
127127
* @param None
128128
* @retval None
129129
*/
130130
void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) {
131+
// this assumes we use NVIC_PriorityGroup_4
131132
NVIC_InitTypeDef NVIC_InitStructure;
132-
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
133133
NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
134-
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
135-
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
134+
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 8;
135+
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
136136
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
137137
NVIC_Init(&NVIC_InitStructure);
138138
}

stm/lib/usbd_storage_msd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
/* Includes ------------------------------------------------------------------*/
2929
#include "usbd_msc_mem.h"
3030
#include "usb_conf.h"
31+
32+
#include "misc.h"
33+
#include "storage.h"
3134
#include "diskio.h"
3235

3336
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
@@ -198,9 +201,9 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
198201
*/
199202

200203

201-
*block_size = 512;
204+
*block_size = storage_get_block_size();
202205
//*block_num = SDCardInfo.CardCapacity / 512;
203-
*block_num = 256 + 128;
206+
*block_num = storage_get_block_count();
204207

205208
return (0);
206209

@@ -305,7 +308,7 @@ int8_t STORAGE_Write (uint8_t lun,
305308
while (SD_GetStatus() != SD_TRANSFER_OK);
306309
#endif
307310
*/
308-
disk_write(0, buf, blk_addr, blk_len);
311+
//disk_write(0, buf, blk_addr, blk_len);
309312
return (0);
310313
}
311314

stm/lib/usbd_usr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ USBD_Usr_cb_TypeDef USR_cb = {
4646
* @retval None
4747
*/
4848
void USBD_USR_Init() {
49-
printf("USB OTG FS\n");
50-
printf("USB device start\n");
49+
//printf("USB OTG FS\n");
50+
//printf("USB device start\n");
5151
}
5252

5353
/**
@@ -57,7 +57,7 @@ void USBD_USR_Init() {
5757
* @retval None
5858
*/
5959
void USBD_USR_DeviceReset(uint8_t speed) {
60-
printf("USB reset %d\n", speed);
60+
//printf("USB reset %d\n", speed);
6161
}
6262

6363
/**
@@ -67,7 +67,7 @@ void USBD_USR_DeviceReset(uint8_t speed) {
6767
* @retval Staus
6868
*/
6969
void USBD_USR_DeviceConfigured() {
70-
printf("USB dev config\n");
70+
//printf("USB dev config\n");
7171
}
7272

7373
/**
@@ -77,7 +77,7 @@ void USBD_USR_DeviceConfigured() {
7777
* @retval None
7878
*/
7979
void USBD_USR_DeviceSuspended() {
80-
printf("USB dev suspend\n");
80+
//printf("USB dev suspend\n");
8181
}
8282

8383
/**
@@ -87,7 +87,7 @@ void USBD_USR_DeviceSuspended() {
8787
* @retval None
8888
*/
8989
void USBD_USR_DeviceResumed() {
90-
printf("USB dev resume\n");
90+
//printf("USB dev resume\n");
9191
}
9292

9393

@@ -98,7 +98,7 @@ void USBD_USR_DeviceResumed() {
9898
* @retval Staus
9999
*/
100100
void USBD_USR_DeviceConnected() {
101-
printf("USB dev connect\n");
101+
//printf("USB dev connect\n");
102102
}
103103

104104

@@ -109,7 +109,7 @@ void USBD_USR_DeviceConnected() {
109109
* @retval Staus
110110
*/
111111
void USBD_USR_DeviceDisconnected() {
112-
printf("USB dev disconn\n");
112+
//printf("USB dev disconn\n");
113113
}
114114

115115
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)