mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-23 22:43:49 +00:00
refractor include chain with following policies
- header file only include what it needs for its declarations.
This commit is contained in:
parent
5ec56120e6
commit
a5b29c5d33
@ -44,7 +44,7 @@ static uint8_t buffer[FIFO_SIZE];
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
fifo_init(&ff, buffer, FIFO_SIZE, 0, 0);
|
||||
fifo_init(&ff, buffer, FIFO_SIZE, 0);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
@ -54,8 +54,8 @@ void tearDown(void)
|
||||
void test_create_null(void)
|
||||
{
|
||||
memset(&ff, 0, sizeof(fifo_t)); // clear fifo to test null created
|
||||
TEST_ASSERT_FALSE( fifo_init(&ff, buffer, 0, 0, 0) );
|
||||
TEST_ASSERT_TRUE( fifo_init(&ff, buffer, 1, 0, 0) );
|
||||
TEST_ASSERT_FALSE( fifo_init(&ff, buffer, 0, 0) );
|
||||
TEST_ASSERT_TRUE( fifo_init(&ff, buffer, 1, 0) );
|
||||
}
|
||||
|
||||
void test_normal(void)
|
||||
|
@ -55,7 +55,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "primitive_types.h"
|
||||
|
||||
/// n-th Bit
|
||||
#define BIT_(n) (1 << (n))
|
||||
|
@ -56,18 +56,23 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//------------- Standard Header -------------//
|
||||
#include "primitive_types.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//------------- TUSB Option Header -------------//
|
||||
#include "tusb_option.h"
|
||||
|
||||
//------------- General Header -------------//
|
||||
#include "compiler/compiler.h"
|
||||
#include "assertion.h"
|
||||
#include "binary.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include "tusb_option.h"
|
||||
#include "hal/hal.h"
|
||||
//------------- TUSB Header -------------//
|
||||
//#include "hal/hal.h"
|
||||
#include "core/tusb_types.h"
|
||||
#include "core/std_descriptors.h"
|
||||
#include "core/std_request.h"
|
||||
|
@ -49,7 +49,7 @@
|
||||
#ifndef _TUSB_ERRORS_H_
|
||||
#define _TUSB_ERRORS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "primitive_types.h"
|
||||
#include "../tusb_option.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -48,8 +48,8 @@
|
||||
/**************************************************************************/
|
||||
static inline void mutex_lock (fifo_t* f)
|
||||
{
|
||||
if (f->irq > 0)
|
||||
NVIC_DisableIRQ(f->irq);
|
||||
// if (f->irq > 0)
|
||||
// NVIC_DisableIRQ(f->irq);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@ -62,8 +62,8 @@ static inline void mutex_lock (fifo_t* f)
|
||||
/**************************************************************************/
|
||||
static inline void mutex_unlock (fifo_t* f)
|
||||
{
|
||||
if (f->irq > 0)
|
||||
NVIC_EnableIRQ(f->irq);
|
||||
// if (f->irq > 0)
|
||||
// NVIC_EnableIRQ(f->irq);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@ -84,7 +84,7 @@ static inline void mutex_unlock (fifo_t* f)
|
||||
Set the -1 if not required.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQn_Type irq)
|
||||
bool fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable) //, IRQn_Type irq)
|
||||
{
|
||||
ASSERT(size > 0, false);
|
||||
|
||||
@ -92,7 +92,7 @@ bool fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQ
|
||||
f->size = size;
|
||||
f->rd_ptr = f->wr_ptr = f->len = 0;
|
||||
f->overwritable = overwritable;
|
||||
f->irq = irq;
|
||||
// f->irq = irq;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ typedef struct _fifo_t
|
||||
volatile uint16_t wr_ptr ; ///< write pointer
|
||||
volatile uint16_t rd_ptr ; ///< read pointer
|
||||
bool overwritable ; ///< allow overwrite data when full
|
||||
IRQn_Type irq ; ///< TODO (abstract later) interrupt used to lock fifo
|
||||
// IRQn_Type irq ; ///< TODO (abstract later) interrupt used to lock fifo
|
||||
} fifo_t;
|
||||
|
||||
bool fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQn_Type irq);
|
||||
bool fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable); //, IRQn_Type irq);
|
||||
bool fifo_write(fifo_t* f, uint8_t data);
|
||||
bool fifo_read(fifo_t* f, uint8_t *data);
|
||||
uint16_t fifo_read_n(fifo_t* f, uint8_t * rx, uint16_t maxlen);
|
||||
|
@ -52,7 +52,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common/common.h"
|
||||
#include "tusb_option.h"
|
||||
#include "common/primitive_types.h"
|
||||
#include "common/compiler/compiler.h"
|
||||
#include "common/binary.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// STANDARD DESCRIPTORS
|
||||
|
@ -55,7 +55,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common/common.h"
|
||||
#include "tusb_option.h"
|
||||
#include "common/primitive_types.h"
|
||||
#include "common/compiler/compiler.h"
|
||||
#include "common/binary.h"
|
||||
|
||||
typedef ATTR_PREPACKED struct ATTR_PACKED {
|
||||
struct {
|
||||
|
@ -53,6 +53,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tusb_option.h"
|
||||
#include "common/primitive_types.h"
|
||||
#include "common/compiler/compiler.h"
|
||||
#include "common/binary.h"
|
||||
|
||||
/// defined base on EHCI specs value for Endpoint Speed
|
||||
typedef enum {
|
||||
TUSB_SPEED_FULL = 0,
|
||||
|
@ -55,8 +55,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tusb_option.h"
|
||||
#include "common/compiler/compiler.h"
|
||||
#include "common/errors.h"
|
||||
|
||||
#define MCU_LPC13UXX 1
|
||||
#define MCU_LPC11UXX 2
|
||||
|
@ -52,7 +52,7 @@
|
||||
#define _TUSB_HAL_LPC43XX_H_
|
||||
|
||||
#include "LPC43xx.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
//#include "lpc43xx_cgu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user