Update chopstx
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2016-05-12 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* chopstx: Update
|
||||||
|
* src/sys.c: Update from Chopstx.
|
||||||
|
* src/usb_lld.h: Likewise.
|
||||||
|
* src/usb_stm32f103.c: Likewise.
|
||||||
|
|
||||||
|
* src/usb_ctrl.c (usb_intr): Follow the change of USB API.
|
||||||
|
* src/main.c (usb_cb_rx_ready, usb_cb_tx_done): Likewise.
|
||||||
|
|
||||||
|
* src/adc.h: Remove unused declarations.
|
||||||
|
|
||||||
2016-03-08 Niibe Yutaka <gniibe@fsij.org>
|
2016-03-08 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__):
|
* tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__):
|
||||||
|
|||||||
2
chopstx
2
chopstx
Submodule chopstx updated: a30a069ed8...fabd271196
@@ -1,15 +1,7 @@
|
|||||||
extern chopstx_mutex_t adc_mtx;
|
|
||||||
extern chopstx_cond_t adc_cond;
|
|
||||||
extern int adc_waiting;
|
|
||||||
extern int adc_data_available;
|
|
||||||
|
|
||||||
void adc_init (void);
|
void adc_init (void);
|
||||||
void adc_start (void);
|
void adc_start (void);
|
||||||
void adc_stop (void);
|
void adc_stop (void);
|
||||||
|
|
||||||
#define ADC_SAMPLE_MODE 0
|
|
||||||
#define ADC_CRC32_MODE 1
|
|
||||||
|
|
||||||
extern uint32_t adc_buf[64];
|
extern uint32_t adc_buf[64];
|
||||||
|
|
||||||
void adc_start_conversion (int offset, int count);
|
void adc_start_conversion (int offset, int count);
|
||||||
|
|||||||
59
src/main.c
59
src/main.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* main.c - main routine of Gnuk
|
* main.c - main routine of Gnuk
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010, 2011, 2012, 2013, 2015
|
* Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016
|
||||||
* Free Software Initiative of Japan
|
* Free Software Initiative of Japan
|
||||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
*
|
*
|
||||||
@@ -85,21 +85,6 @@ _write (const char *s, int len)
|
|||||||
chopstx_mutex_unlock (&stdout.m);
|
chopstx_mutex_unlock (&stdout.m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
EP3_IN_Callback (void)
|
|
||||||
{
|
|
||||||
chopstx_mutex_lock (&stdout.m_dev);
|
|
||||||
chopstx_cond_signal (&stdout.cond_dev);
|
|
||||||
chopstx_mutex_unlock (&stdout.m_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
EP5_OUT_Callback (void)
|
|
||||||
{
|
|
||||||
chopstx_mutex_lock (&stdout.m_dev);
|
|
||||||
usb_lld_rx_enable (ENDP5);
|
|
||||||
chopstx_mutex_unlock (&stdout.m_dev);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
_write (const char *s, int size)
|
_write (const char *s, int size)
|
||||||
@@ -111,6 +96,48 @@ _write (const char *s, int size)
|
|||||||
|
|
||||||
extern void *USBthread (void *arg);
|
extern void *USBthread (void *arg);
|
||||||
|
|
||||||
|
extern void EP1_IN_Callback (void);
|
||||||
|
extern void EP2_IN_Callback (void);
|
||||||
|
extern void EP1_OUT_Callback (void);
|
||||||
|
extern void EP6_IN_Callback (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
usb_cb_rx_ready (uint8_t ep_num)
|
||||||
|
{
|
||||||
|
if (ep_num == ENDP1)
|
||||||
|
EP1_OUT_Callback ();
|
||||||
|
#ifdef DEBUG
|
||||||
|
else if (ep_num == ENDP5)
|
||||||
|
{
|
||||||
|
chopstx_mutex_lock (&stdout.m_dev);
|
||||||
|
usb_lld_rx_enable (ep_num);
|
||||||
|
chopstx_mutex_unlock (&stdout.m_dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usb_cb_tx_done (uint8_t ep_num)
|
||||||
|
{
|
||||||
|
if (ep_num == ENDP1)
|
||||||
|
EP1_IN_Callback ();
|
||||||
|
else if (ep_num == ENDP2)
|
||||||
|
EP2_IN_Callback ();
|
||||||
|
#ifdef DEBUG
|
||||||
|
else if (ep_num == ENDP3)
|
||||||
|
{
|
||||||
|
chopstx_mutex_lock (&stdout.m_dev);
|
||||||
|
chopstx_cond_signal (&stdout.cond_dev);
|
||||||
|
chopstx_mutex_unlock (&stdout.m_dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef PINPAD_SUPPORT
|
||||||
|
else if (ep_num == ENDP6)
|
||||||
|
EP6_IN_Callback ();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main thread does 1-bit LED display output
|
* main thread does 1-bit LED display output
|
||||||
*/
|
*/
|
||||||
|
|||||||
24
src/sys.c
24
src/sys.c
@@ -17,7 +17,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#include "clk_gpio_init.c"
|
#include "clk_gpio_init-stm32.c"
|
||||||
|
|
||||||
#define CORTEX_PRIORITY_BITS 4
|
#define CORTEX_PRIORITY_BITS 4
|
||||||
#define CORTEX_PRIORITY_MASK(n) ((n) << (8 - CORTEX_PRIORITY_BITS))
|
#define CORTEX_PRIORITY_MASK(n) ((n) << (8 - CORTEX_PRIORITY_BITS))
|
||||||
@@ -25,17 +25,17 @@
|
|||||||
#define STM32_USB_IRQ_PRIORITY 11
|
#define STM32_USB_IRQ_PRIORITY 11
|
||||||
|
|
||||||
struct NVIC {
|
struct NVIC {
|
||||||
uint32_t ISER[8];
|
volatile uint32_t ISER[8];
|
||||||
uint32_t unused1[24];
|
volatile uint32_t unused1[24];
|
||||||
uint32_t ICER[8];
|
volatile uint32_t ICER[8];
|
||||||
uint32_t unused2[24];
|
volatile uint32_t unused2[24];
|
||||||
uint32_t ISPR[8];
|
volatile uint32_t ISPR[8];
|
||||||
uint32_t unused3[24];
|
volatile uint32_t unused3[24];
|
||||||
uint32_t ICPR[8];
|
volatile uint32_t ICPR[8];
|
||||||
uint32_t unused4[24];
|
volatile uint32_t unused4[24];
|
||||||
uint32_t IABR[8];
|
volatile uint32_t IABR[8];
|
||||||
uint32_t unused5[56];
|
volatile uint32_t unused5[56];
|
||||||
uint32_t IPR[60];
|
volatile uint32_t IPR[60];
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct NVIC *const NVICBase = ((struct NVIC *const)0xE000E100);
|
static struct NVIC *const NVICBase = ((struct NVIC *const)0xE000E100);
|
||||||
|
|||||||
@@ -199,13 +199,7 @@ usb_cb_device_reset (void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Set DEVICE as not configured */
|
usb_lld_reset (USB_INITIAL_FEATURE);
|
||||||
usb_lld_set_configuration (0);
|
|
||||||
|
|
||||||
/* Current Feature initialization */
|
|
||||||
usb_lld_set_feature (USB_INITIAL_FEATURE);
|
|
||||||
|
|
||||||
usb_lld_reset ();
|
|
||||||
|
|
||||||
/* Initialize Endpoint 0 */
|
/* Initialize Endpoint 0 */
|
||||||
usb_lld_setup_endpoint (ENDP0, EP_CONTROL, 0, ENDP0_RXADDR, ENDP0_TXADDR,
|
usb_lld_setup_endpoint (ENDP0, EP_CONTROL, 0, ENDP0_RXADDR, ENDP0_TXADDR,
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ int usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
|
|||||||
int usb_cb_handle_event (uint8_t event_type, uint16_t value);
|
int usb_cb_handle_event (uint8_t event_type, uint16_t value);
|
||||||
void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
|
void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
|
||||||
struct req_args *arg);
|
struct req_args *arg);
|
||||||
|
void usb_cb_tx_done (uint8_t ep_num);
|
||||||
|
void usb_cb_rx_ready (uint8_t ep_num);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
USB_EVENT_ADDRESS,
|
USB_EVENT_ADDRESS,
|
||||||
@@ -102,13 +104,12 @@ int usb_lld_reply_request (const void *buf, size_t buflen,
|
|||||||
void usb_lld_rx_enable (int ep_num);
|
void usb_lld_rx_enable (int ep_num);
|
||||||
int usb_lld_rx_data_len (int ep_num);
|
int usb_lld_rx_data_len (int ep_num);
|
||||||
void usb_lld_rxcpy (uint8_t *dst, int ep_num, int offset, size_t len);
|
void usb_lld_rxcpy (uint8_t *dst, int ep_num, int offset, size_t len);
|
||||||
void usb_lld_reset (void);
|
void usb_lld_reset (uint8_t feature);
|
||||||
void usb_lld_setup_endpoint (int ep_num, int ep_type, int ep_kind,
|
void usb_lld_setup_endpoint (int ep_num, int ep_type, int ep_kind,
|
||||||
int ep_rx_addr, int ep_tx_addr,
|
int ep_rx_addr, int ep_tx_addr,
|
||||||
int ep_rx_memory_size);
|
int ep_rx_memory_size);
|
||||||
void usb_lld_set_configuration (uint8_t config);
|
void usb_lld_set_configuration (uint8_t config);
|
||||||
uint8_t usb_lld_current_configuration (void);
|
uint8_t usb_lld_current_configuration (void);
|
||||||
void usb_lld_set_feature (uint8_t feature);
|
|
||||||
void usb_lld_set_data_to_recv (void *p, size_t len);
|
void usb_lld_set_data_to_recv (void *p, size_t len);
|
||||||
|
|
||||||
void usb_lld_prepare_shutdown (void);
|
void usb_lld_prepare_shutdown (void);
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ void usb_lld_init (uint8_t feature)
|
|||||||
dev_p->state = IN_DATA;
|
dev_p->state = IN_DATA;
|
||||||
|
|
||||||
usb_lld_set_configuration (0);
|
usb_lld_set_configuration (0);
|
||||||
usb_lld_set_feature (feature);
|
dev_p->current_feature = feature;
|
||||||
|
|
||||||
/* Reset USB */
|
/* Reset USB */
|
||||||
st103_set_cntr (CNTR_FRES);
|
st103_set_cntr (CNTR_FRES);
|
||||||
@@ -478,7 +478,7 @@ static int std_get_status (uint8_t req, struct req_args *arg)
|
|||||||
uint16_t status_info = 0;
|
uint16_t status_info = 0;
|
||||||
|
|
||||||
if (arg->value != 0 || arg->len != 2 || (arg->index >> 8) != 0
|
if (arg->value != 0 || arg->len != 2 || (arg->index >> 8) != 0
|
||||||
|| (req & REQUEST_DIR) == 0)
|
|| USB_SETUP_SET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT)
|
if (rcp == DEVICE_RECIPIENT)
|
||||||
@@ -551,7 +551,7 @@ static int std_clear_feature (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 1)
|
if (USB_SETUP_GET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT)
|
if (rcp == DEVICE_RECIPIENT)
|
||||||
@@ -601,7 +601,7 @@ static int std_set_feature (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 1)
|
if (USB_SETUP_GET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT)
|
if (rcp == DEVICE_RECIPIENT)
|
||||||
@@ -654,7 +654,7 @@ static int std_set_address (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 1)
|
if (USB_SETUP_GET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT && arg->len == 0 && arg->value <= 127
|
if (rcp == DEVICE_RECIPIENT && arg->len == 0 && arg->value <= 127
|
||||||
@@ -668,7 +668,7 @@ static int std_get_descriptor (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 0)
|
if (USB_SETUP_SET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
return usb_cb_get_descriptor (rcp, (arg->value >> 8),
|
return usb_cb_get_descriptor (rcp, (arg->value >> 8),
|
||||||
@@ -679,7 +679,7 @@ static int std_get_configuration (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 0)
|
if (USB_SETUP_SET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT)
|
if (rcp == DEVICE_RECIPIENT)
|
||||||
@@ -692,7 +692,7 @@ static int std_set_configuration (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 1)
|
if (USB_SETUP_GET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == DEVICE_RECIPIENT && arg->index == 0 && arg->len == 0)
|
if (rcp == DEVICE_RECIPIENT && arg->index == 0 && arg->len == 0)
|
||||||
@@ -705,7 +705,7 @@ static int std_get_interface (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 0)
|
if (USB_SETUP_SET (req))
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
|
|
||||||
if (rcp == INTERFACE_RECIPIENT)
|
if (rcp == INTERFACE_RECIPIENT)
|
||||||
@@ -726,7 +726,7 @@ static int std_set_interface (uint8_t req, struct req_args *arg)
|
|||||||
{
|
{
|
||||||
uint8_t rcp = req & RECIPIENT;
|
uint8_t rcp = req & RECIPIENT;
|
||||||
|
|
||||||
if ((req & REQUEST_DIR) == 1 || rcp != INTERFACE_RECIPIENT
|
if (USB_SETUP_GET (req) || rcp != INTERFACE_RECIPIENT
|
||||||
|| arg->len != 0 || (arg->index >> 8) != 0
|
|| arg->len != 0 || (arg->index >> 8) != 0
|
||||||
|| (arg->value >> 8) != 0 || dev_p->current_configuration == 0)
|
|| (arg->value >> 8) != 0 || dev_p->current_configuration == 0)
|
||||||
return USB_UNSUPPORT;
|
return USB_UNSUPPORT;
|
||||||
@@ -843,27 +843,6 @@ static void handle_out0 (void)
|
|||||||
dev_p->state = STALLED;
|
dev_p->state = STALLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nop_proc (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#define WEAK __attribute__ ((weak, alias ("nop_proc")))
|
|
||||||
void WEAK EP1_IN_Callback (void);
|
|
||||||
void WEAK EP2_IN_Callback (void);
|
|
||||||
void WEAK EP3_IN_Callback (void);
|
|
||||||
void WEAK EP4_IN_Callback (void);
|
|
||||||
void WEAK EP5_IN_Callback (void);
|
|
||||||
void WEAK EP6_IN_Callback (void);
|
|
||||||
void WEAK EP7_IN_Callback (void);
|
|
||||||
|
|
||||||
void WEAK EP1_OUT_Callback (void);
|
|
||||||
void WEAK EP2_OUT_Callback (void);
|
|
||||||
void WEAK EP3_OUT_Callback (void);
|
|
||||||
void WEAK EP4_OUT_Callback (void);
|
|
||||||
void WEAK EP5_OUT_Callback (void);
|
|
||||||
void WEAK EP6_OUT_Callback (void);
|
|
||||||
void WEAK EP7_OUT_Callback (void);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usb_handle_transfer (uint16_t istr_value)
|
usb_handle_transfer (uint16_t istr_value)
|
||||||
{
|
{
|
||||||
@@ -901,37 +880,21 @@ usb_handle_transfer (uint16_t istr_value)
|
|||||||
if ((ep_value & EP_CTR_RX))
|
if ((ep_value & EP_CTR_RX))
|
||||||
{
|
{
|
||||||
st103_ep_clear_ctr_rx (ep_index);
|
st103_ep_clear_ctr_rx (ep_index);
|
||||||
switch ((ep_index - 1))
|
usb_cb_rx_ready (ep_index);
|
||||||
{
|
|
||||||
case 0: EP1_OUT_Callback (); break;
|
|
||||||
case 1: EP2_OUT_Callback (); break;
|
|
||||||
case 2: EP3_OUT_Callback (); break;
|
|
||||||
case 3: EP4_OUT_Callback (); break;
|
|
||||||
case 4: EP5_OUT_Callback (); break;
|
|
||||||
case 5: EP6_OUT_Callback (); break;
|
|
||||||
case 6: EP7_OUT_Callback (); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ep_value & EP_CTR_TX))
|
if ((ep_value & EP_CTR_TX))
|
||||||
{
|
{
|
||||||
st103_ep_clear_ctr_tx (ep_index);
|
st103_ep_clear_ctr_tx (ep_index);
|
||||||
switch ((ep_index - 1))
|
usb_cb_tx_done (ep_index);
|
||||||
{
|
|
||||||
case 0: EP1_IN_Callback (); break;
|
|
||||||
case 1: EP2_IN_Callback (); break;
|
|
||||||
case 2: EP3_IN_Callback (); break;
|
|
||||||
case 3: EP4_IN_Callback (); break;
|
|
||||||
case 4: EP5_IN_Callback (); break;
|
|
||||||
case 5: EP6_IN_Callback (); break;
|
|
||||||
case 6: EP7_IN_Callback (); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_lld_reset (void)
|
void usb_lld_reset (uint8_t feature)
|
||||||
{
|
{
|
||||||
|
usb_lld_set_configuration (0);
|
||||||
|
dev_p->current_feature = feature;
|
||||||
st103_set_btable ();
|
st103_set_btable ();
|
||||||
st103_set_daddr (0);
|
st103_set_daddr (0);
|
||||||
}
|
}
|
||||||
@@ -1038,11 +1001,6 @@ uint8_t usb_lld_current_configuration (void)
|
|||||||
return dev_p->current_configuration;
|
return dev_p->current_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_lld_set_feature (uint8_t feature)
|
|
||||||
{
|
|
||||||
dev_p->current_feature = feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
void usb_lld_set_data_to_recv (void *p, size_t len)
|
void usb_lld_set_data_to_recv (void *p, size_t len)
|
||||||
{
|
{
|
||||||
data_p->addr = p;
|
data_p->addr = p;
|
||||||
|
|||||||
Reference in New Issue
Block a user