Subversion Repositories svn.mios32

Compare Revisions

Regard whitespace Rev 2656 → Rev 2657

/branches/mcan/include/mios32/mios32_can_midi.h
87,17 → 87,18
/////////////////////////////////////////////////////////////////////////////
 
typedef union {
can_packet_t packet;
mios32_can_packet_t packet;
struct {
can_ext_id_t id;
can_ctrl_t ctrl;
can_data_t data;
mios32_can_ext_id_t id;
mios32_can_ctrl_t ctrl;
mios32_can_data_t data;
};
} mcan_packet_t;
} mios32_mcan_packet_t;
 
 
typedef union {
struct {
can_ext_id_t id;
mios32_can_ext_id_t id;
u16 data_l;
};
struct {
120,7 → 121,7
u8 src_port;
u8 dst_port;
};
} mcan_header_t;
} mios32_mcan_header_t;
 
 
/////////////////////////////////////////////////////////////////////////////
142,26 → 143,26
 
extern s32 MIOS32_CAN_MIDI_Periodic_mS(void);
 
extern s32 MIOS32_CAN_MIDI_PacketTransmit_NonBlocking(mcan_packet_t p);
extern s32 MIOS32_CAN_MIDI_PacketTransmit(mcan_packet_t p);
extern s32 MIOS32_CAN_MIDI_PacketTransmit_NonBlocking(mios32_mcan_packet_t p);
extern s32 MIOS32_CAN_MIDI_PacketTransmit(mios32_mcan_packet_t p);
 
extern s32 MIOS32_CAN_MIDI_PacketSend_NonBlocking(mcan_header_t header, mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_PacketSend(mcan_header_t header, mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_PacketSend_NonBlocking(mios32_mcan_header_t header, mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_PacketSend(mios32_mcan_header_t header, mios32_midi_package_t package);
 
extern s32 MIOS32_CAN_MIDI_PackageSend_NonBlocking(mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_PackageSend(mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_SysexRepackSend(mcan_header_t header, mios32_midi_package_t package);
extern s32 MIOS32_CAN_MIDI_SysexRepackSend(mios32_mcan_header_t header, mios32_midi_package_t package);
 
extern s32 MIOS32_CAN_MIDI_SysexSend_NonBlocking(mcan_header_t header, u8 *stream, u16 size);
extern s32 MIOS32_CAN_MIDI_SysexSend(mcan_header_t header, u8 *stream, u16 size);
extern s32 MIOS32_CAN_MIDI_SysexSend_NonBlocking(mios32_mcan_header_t header, u8 *stream, u16 size);
extern s32 MIOS32_CAN_MIDI_SysexSend(mios32_mcan_header_t header, u8 *stream, u16 size);
 
extern s32 MIOS32_CAN_MIDI_SysExStreamCallback_Init(s32 (*callback_sysex_stream)(mcan_header_t header, u8* stream, u16 size));
extern s32 MIOS32_CAN_MIDI_SysExStreamCallback_Init(s32 (*callback_sysex_stream)(mios32_mcan_header_t header, u8* stream, u16 size));
 
extern s32 MIOS32_CAN_MIDI_PackageCallback_Init(s32 (*direct_package_callback)(mcan_header_t header, mios32_midi_package_t package));
extern s32 MIOS32_CAN_MIDI_PackageCallback_Init(s32 (*direct_package_callback)(mios32_mcan_header_t header, mios32_midi_package_t package));
 
extern s32 MIOS32_CAN_MIDI_PackageReceive(mios32_midi_package_t *package);
 
extern u32 MIOS32_CAN_MIDI_DefaultHeaderInit(mcan_header_t* header);
extern u32 MIOS32_CAN_MIDI_DefaultHeaderInit(mios32_mcan_header_t* header);
/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////
/branches/mcan/include/mios32/mios32_can.h
81,7 → 81,7
u16 :11;
};
} can_std_id_t;
} mios32_can_std_id_t;
 
// CAN Extended 29bits Id(32Bits reg), CAN_RIxR/CAN_TIxR
typedef union {
114,7 → 114,7
u32 lpc_ctrl:2; // special field for lpc,
u32 ext_id:29;
};
} can_ext_id_t;
} mios32_can_ext_id_t;
 
// CAN control registers CAN_TDTxR/CAN_RDTxR
typedef union {
131,7 → 131,7
u32 tgt:1;
u32 :23;
};
} can_ctrl_t;
} mios32_can_ctrl_t;
 
// CAN data registers CAN_TDLxR/CAN_TDHxR/CAN_RDLxR/CAN_RDHxR
typedef union {
148,26 → 148,26
struct {
u8 bytes[8];
};
} can_data_t;
} mios32_can_data_t;
 
// CAN mailboxes packet
typedef struct can_packet_t {
can_ext_id_t id;
can_ctrl_t ctrl;
can_data_t data;
} can_packet_t;
typedef struct mios32_can_packet_t {
mios32_can_ext_id_t id;
mios32_can_ctrl_t ctrl;
mios32_can_data_t data;
} mios32_can_packet_t;
 
// CAN 16bits filter
typedef struct can_std_filter_t {
can_std_id_t filt;
can_std_id_t mask;
} can_std_filter_t;
typedef struct mios32_can_std_filter_t {
mios32_can_std_id_t filt;
mios32_can_std_id_t mask;
} mios32_can_std_filter_t;
 
// CAN 32bits filter
typedef struct can_ext_filter_t {
can_ext_id_t filt;
can_ext_id_t mask;
} can_ext_filter_t;
typedef struct mios32_can_ext_filter_t {
mios32_can_ext_id_t filt;
mios32_can_ext_id_t mask;
} mios32_can_ext_filter_t;
 
// CAN bus state
typedef enum {
175,7 → 175,7
WARNING = 1,
PASSIVE = 0,
BUS_OFF = -1
} can_bus_stat_t;
} mios32_can_bus_stat_t;
 
// CAN error staus
typedef union {
202,19 → 202,19
u32 tec:8;
u32 rec:8;
};
} can_stat_err_t;
} mios32_can_stat_err_t;
 
// CAN status report
typedef struct can_stat_report_t {
typedef struct mios32_can_stat_report_t {
u32 rx_packets_err;
u32 tx_packets_ctr;
u32 rx_packets_ctr;
u32 rx_buff_err_ctr;
u8 rx_last_buff_err;
can_bus_stat_t bus_state;
can_stat_err_t bus_curr_err;
can_stat_err_t bus_last_err;
} can_stat_report_t;
mios32_can_bus_stat_t bus_state;
mios32_can_stat_err_t bus_curr_err;
mios32_can_stat_err_t bus_last_err;
} mios32_can_stat_report_t;
 
/////////////////////////////////////////////////////////////////////////////
// Prototypes
229,35 → 229,34
extern s32 MIOS32_CAN_InitPort(u8 can, u8 is_midi);
extern s32 MIOS32_CAN_InitPortDefault(u8 can);
extern s32 MIOS32_CAN_InitPeriph(u8 can);
extern s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled);
extern s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled);
extern s32 MIOS32_CAN_InitPacket(can_packet_t *packet);
extern s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled);
extern s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled);
extern s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet);
 
extern s32 MIOS32_CAN_RxBufferFree(u8 can);
extern s32 MIOS32_CAN_RxBufferUsed(u8 can);
extern s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p);
extern s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p);
extern s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p);
extern s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p);
extern s32 MIOS32_CAN_RxBufferRemove(u8 can);
extern s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p);
extern s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p);
 
extern s32 MIOS32_CAN_TxBufferFree(u8 can);
extern s32 MIOS32_CAN_TxBufferUsed(u8 can);
extern s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p);
extern s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len);
extern s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len);
extern s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p);
extern s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p);
extern s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p);
extern s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len);
extern s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len);
extern s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p);
extern s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p);
 
extern s32 MIOS32_CAN_BusErrorCheck(u8 can);
 
extern s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time);
extern s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time);
 
extern s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err);
extern s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report);
extern s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err);
extern s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report);
extern s32 MIOS32_CAN_ReportReset(u8 can);
/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////
extern u32 can_temp;
 
#endif /* _MIOS32_CAN_H */
/branches/mcan/mios32/STM32F4xx/mios32_can.c
96,17 → 96,17
 
#if NUM_SUPPORTED_CANS >= 1
static u8 can_assigned_to_midi;
static can_packet_t rx_buffer[NUM_SUPPORTED_CANS][MIOS32_CAN_RX_BUFFER_SIZE];
static mios32_can_packet_t rx_buffer[NUM_SUPPORTED_CANS][MIOS32_CAN_RX_BUFFER_SIZE];
static volatile u16 rx_buffer_tail[NUM_SUPPORTED_CANS];
static volatile u16 rx_buffer_head[NUM_SUPPORTED_CANS];
static volatile u16 rx_buffer_size[NUM_SUPPORTED_CANS];
 
static can_packet_t tx_buffer[NUM_SUPPORTED_CANS][MIOS32_CAN_TX_BUFFER_SIZE];
static mios32_can_packet_t tx_buffer[NUM_SUPPORTED_CANS][MIOS32_CAN_TX_BUFFER_SIZE];
static volatile u16 tx_buffer_tail[NUM_SUPPORTED_CANS];
static volatile u16 tx_buffer_head[NUM_SUPPORTED_CANS];
static volatile u16 tx_buffer_size[NUM_SUPPORTED_CANS];
 
static can_stat_report_t can_stat_report[NUM_SUPPORTED_CANS];
static mios32_can_stat_report_t can_stat_report[NUM_SUPPORTED_CANS];
#endif
 
#if defined MIOS32_CAN_VERBOSE
115,10 → 115,7
static u8 can_verbose = 0;
#endif
 
u32 can_temp;
 
 
 
/////////////////////////////////////////////////////////////////////////////
//! Initializes CAN MIDI layer
//! \param[in] mode currently only mode 0 supported
422,7 → 419,7
//! \param[in] extended id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled)
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
453,7 → 450,7
//! \param[in] standard id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled)
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
485,7 → 482,7
//! \return -2: function not prepared for this CAN
//! \return -3: CAN Initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_InitPacket(can_packet_t *packet)
s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
547,7 → 544,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
581,7 → 578,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
640,7 → 637,7
//! \return -2 if buffer full (retry)
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
714,7 → 711,7
//! \return >= 0: transmitted byte
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
749,7 → 746,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len)
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
824,7 → 821,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len)
s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len)
{
s32 error;
844,7 → 841,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p)
{
// for more comfortable usage...
// -> just forward to MIOS32_CAN_TxBufferPutMore
862,7 → 859,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p)
{
s32 error;
888,7 → 885,7
return -1; // no CAN available
#else
 
can_stat_err_t err;
mios32_can_stat_err_t err;
err = can_stat_report[can].bus_last_err;
//if((CANx->ESR &7)!=0){
if((err.tec) > (can_stat_report[can].bus_curr_err.tec)){
967,7 → 964,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time)
s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
1028,7 → 1025,7
if( MIOS32_CAN1->TSR & CAN_TSR_TME0)mailbox = 0;
else if( MIOS32_CAN1->TSR & CAN_TSR_TME1)mailbox = 1;
else if( MIOS32_CAN1->TSR & CAN_TSR_TME2)mailbox = 2;
can_packet_t p;
mios32_can_packet_t p;
MIOS32_CAN_TxBufferGet(0, &p);
p.id.txrq = 1; //TX Req flag, this reset RQCPx
MIOS32_CAN1->sTxMailBox[mailbox].TDTR = p.ctrl.ALL;
1050,7 → 1047,7
while(MIOS32_CAN1->RF0R & CAN_RF0R_FMP0){ // FMP0 contains number of messages
// get EID, MSG and DLC
can_packet_t p;
mios32_can_packet_t p;
p.id.ALL = MIOS32_CAN1->sFIFOMailBox[0].RIR;
p.ctrl.ALL = MIOS32_CAN1->sFIFOMailBox[0].RDTR;
p.data.data_l = MIOS32_CAN1->sFIFOMailBox[0].RDLR;
1107,7 → 1104,7
while(MIOS32_CAN1->RF1R & CAN_RF1R_FMP1){ // FMP1 contains number of messages
// get EID, MSG and DLC
can_packet_t p;
mios32_can_packet_t p;
p.id.ALL = MIOS32_CAN1->sFIFOMailBox[1].RIR;
p.ctrl.ALL = MIOS32_CAN1->sFIFOMailBox[1].RDTR;
p.data.data_l = MIOS32_CAN1->sFIFOMailBox[1].RDLR;
1159,7 → 1156,7
if( CAN_GetITStatus(MIOS32_CAN1, CAN_IT_ERR) ) { // General Err interrupt is enabled
 
if( (can_stat_report[0].bus_last_err.ALL & 7) != (MIOS32_CAN1->ESR & 7) ){
//can_stat_err_t err = MIOS32_CAN1->ESR;
//mios32_can_stat_err_t err = MIOS32_CAN1->ESR;
can_stat_report[0].bus_last_err.ALL = MIOS32_CAN1->ESR;
//if(can_verbose)MIOS32_MIDI_SendDebugMessage("0x%0x", can_stat_report[0].bus_last_err.ALL & 7);
1206,7 → 1203,7
if( MIOS32_CAN2->TSR & CAN_TSR_TME0)mailbox = 0;
else if( MIOS32_CAN2->TSR & CAN_TSR_TME1)mailbox = 1;
else if( MIOS32_CAN2->TSR & CAN_TSR_TME2)mailbox = 2;
can_packet_t p;
mios32_can_packet_t p;
MIOS32_CAN_TxBufferGet(1, &p);
p.id.txrq = 1; //TX Req flag, this reset RQCPx
MIOS32_CAN2->sTxMailBox[mailbox].TDTR = p.ctrl.ALL;
1228,7 → 1225,7
{
while(MIOS32_CAN2->RF0R & CAN_RF0R_FMP0){ // FMP0 contains number of messages
// get EID, MSG and DLC
can_packet_t p;
mios32_can_packet_t p;
p.id.ALL = MIOS32_CAN2->sFIFOMailBox[0].RIR;
p.ctrl.ALL = MIOS32_CAN2->sFIFOMailBox[0].RDTR;
p.data.data_l = MIOS32_CAN2->sFIFOMailBox[0].RDLR;
1249,7 → 1246,7
{
while(MIOS32_CAN2->RF1R & CAN_RF1R_FMP1 ){ // FMP1 contains number of messages
// get EID, MSG and DLC
can_packet_t p;
mios32_can_packet_t p;
p.id.ALL = MIOS32_CAN2->sFIFOMailBox[1].RIR;
p.ctrl.ALL = MIOS32_CAN2->sFIFOMailBox[1].RDTR;
p.data.data_l = MIOS32_CAN2->sFIFOMailBox[1].RDLR;
1313,7 → 1310,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err)
s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
1326,7 → 1323,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report)
s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
/branches/mcan/mios32/LPC17xx/mios32_can.c
157,7 → 157,7
//! \param[in] extended id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled)
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
173,7 → 173,7
//! \param[in] standard id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled)
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
189,7 → 189,7
//! \return -2: function not prepared for this CAN
//! \return -3: CAN Initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_InitPacket(can_packet_t *packet)
s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
240,7 → 240,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
258,7 → 258,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
293,7 → 293,7
//! \return -2 if buffer full (retry)
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
350,7 → 350,7
//! \return >= 0: transmitted byte
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
371,7 → 371,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len)
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
391,7 → 391,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len)
s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len)
{
s32 error;
411,7 → 411,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p)
{
// for more comfortable usage...
// -> just forward to MIOS32_CAN_TxBufferPutMore
429,7 → 429,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p)
{
s32 error;
469,7 → 469,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time)
s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
481,7 → 481,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err)
s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
493,7 → 493,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report)
s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
/branches/mcan/mios32/STM32F10x/mios32_can.c
157,7 → 157,7
//! \param[in] extended id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled)
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
173,7 → 173,7
//! \param[in] standard id for mask
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled)
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled)
{
#if MIOS32_CAN_NUM == 0
return -1; // no CAN enabled
189,7 → 189,7
//! \return -2: function not prepared for this CAN
//! \return -3: CAN Initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_InitPacket(can_packet_t *packet)
s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
240,7 → 240,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
258,7 → 258,7
//! \return >= 0: number of received bytes
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p)
s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
293,7 → 293,7
//! \return -2 if buffer full (retry)
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
350,7 → 350,7
//! \return >= 0: transmitted byte
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p)
s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
371,7 → 371,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len)
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
391,7 → 391,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len)
s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len)
{
s32 error;
411,7 → 411,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p)
{
// for more comfortable usage...
// -> just forward to MIOS32_CAN_TxBufferPutMore
429,7 → 429,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p)
s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p)
{
s32 error;
469,7 → 469,7
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time)
s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
481,7 → 481,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err)
s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
493,7 → 493,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report)
s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report)
{
#if NUM_SUPPORTED_CANS == 0
return -1; // no CAN available
/branches/mcan/mios32/common/mios32_can_midi.c
105,8 → 105,8
static u32 can_last_baudrate;
 
// callback for direct sysex stream
static s32 (*sysex_stream_callback_func)(mcan_header_t header, u8* stream, u16 size);
static s32 (*direct_package_callback_func)(mcan_header_t header, mios32_midi_package_t package);
static s32 (*sysex_stream_callback_func)(mios32_mcan_header_t header, u8* stream, u16 size);
static s32 (*direct_package_callback_func)(mios32_mcan_header_t header, mios32_midi_package_t package);
 
// verbose
static u8 can_midi_verbose = 2;
145,7 → 145,7
/////////////////////////////////////////////////////////////////////////////
 
// internal function to parse configuration commands
static s32 MIOS32_CAN_MIDI_LocalCmdParser(mcan_header_t header, mios32_midi_package_t* package)
static s32 MIOS32_CAN_MIDI_LocalCmdParser(mios32_mcan_header_t header, mios32_midi_package_t* package)
{
#if MIOS32_CAN_NUM > 0
348,8 → 348,8
#else
//u8 i;
//can_ext_filter_t filt32;
can_std_filter_t filt16[2];
//mios32_can_ext_filter_t filt32;
mios32_can_std_filter_t filt16[2];
// /* Node System messages and bypass -> Fifo0 */
// // filter Bank#0, checks for incoming Node SysEx and SysCom messages
479,7 → 479,7
u32 new_frame_rate;
if( MIOS32_CAN_MIDI_CheckAvailable(0) ){
 
can_stat_report_t report;
mios32_can_stat_report_t report;
MIOS32_CAN_ReportGetCurr(0, &report);
 
new_frame_rate = report.rx_packets_ctr - can_last_baudrate;
516,7 → 516,7
//! caller should retry until buffer is free again
//! \note Applications shouldn't call this function directly, instead please use \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_PacketTransmit_NonBlocking(mcan_packet_t p)
s32 MIOS32_CAN_MIDI_PacketTransmit_NonBlocking(mios32_mcan_packet_t p)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled
546,7 → 546,7
//! \return -1: CAN_MIDI device not available
//! \note Applications shouldn't call this function directly, instead please use \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_PacketTransmit(mcan_packet_t p)
s32 MIOS32_CAN_MIDI_PacketTransmit(mios32_mcan_packet_t p)
{
s32 error;
562,7 → 562,7
//! \return 0: no error
//! \note Applications shouldn't call this function directly, instead please use \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_PacketSend_NonBlocking(mcan_header_t header, mios32_midi_package_t package)
s32 MIOS32_CAN_MIDI_PacketSend_NonBlocking(mios32_mcan_header_t header, mios32_midi_package_t package)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled
592,7 → 592,7
error = MIOS32_CAN_MIDI_SysexRepackSend(header, package);
return error;
}else{ // This is not Sysex
mcan_packet_t p;
mios32_mcan_packet_t p;
//p.frame_id = header.frame_id;
u8* byte = &p.data.bytes[0];
p.ctrl.dlc = 0;
646,7 → 646,7
//! \return -1: CAN_MIDI device not available
//! \note Applications shouldn't call this function directly, instead please use \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_PacketSend(mcan_header_t header, mios32_midi_package_t package)
s32 MIOS32_CAN_MIDI_PacketSend(mios32_mcan_header_t header, mios32_midi_package_t package)
{
s32 error;
//DEBUG_MSG("[MIOS32_CAN_MIDI_PackageSend] 0x%08x\n", package.ALL);
666,7 → 666,7
{
s32 error;
mcan_header_t header;
mios32_mcan_header_t header;
MIOS32_CAN_MIDI_DefaultHeaderInit(&header);
header.cable = package.cable;
header.type = package.type;
703,7 → 703,7
//! \return -1: CAN_MIDI device not available
//! \note Applications shouldn't call this function directly, instead please use \ref MIOS32_MIDI layer functions
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_SysexRepackSend(mcan_header_t header, mios32_midi_package_t package)
s32 MIOS32_CAN_MIDI_SysexRepackSend(mios32_mcan_header_t header, mios32_midi_package_t package)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled
778,7 → 778,7
if(rpk->ctr >= 8){ // a full packet is ready
if (rpk->packet == 0)header.type = 0x4; // =>Start
else header.type = 0x6; // =>Cont
mcan_packet_t p;
mios32_mcan_packet_t p;
// copy id
p.id = header.id;
// dlc
796,7 → 796,7
if(rpk->stat.ending == 1){ // this is last packet
if (rpk->packet == 0)header.type = 0x4; // =>Start(special case only one packet stream)
else header.type = 0x7; // =>End
mcan_packet_t p;
mios32_mcan_packet_t p;
// copy id
p.id = header.id;
// dlc
824,7 → 824,7
//! \return 0: no error
//! \return -1: CAN_MIDI device not available
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_SysexSend_NonBlocking(mcan_header_t header, u8 *stream, u16 size)
s32 MIOS32_CAN_MIDI_SysexSend_NonBlocking(mios32_mcan_header_t header, u8 *stream, u16 size)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled
838,7 → 838,7
// Prepare the Packet
s32 error;
mcan_packet_t p;
mios32_mcan_packet_t p;
p.ctrl.ALL = 0;
p.data.data_l = 0;
p.data.data_h = 0;
909,7 → 909,7
//! \return 0: no error
//! \return -1: CAN_MIDI device not available
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_SysexSend(mcan_header_t header, u8 *stream, u16 size)
s32 MIOS32_CAN_MIDI_SysexSend(mios32_mcan_header_t header, u8 *stream, u16 size)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled - accordingly no package in buffer
959,7 → 959,7
//! With return value != 0, APP_MIDI_NotifyPackage() won't get the already processed package.
//! \return < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_SysExStreamCallback_Init(s32 (*callback_sysex_stream)(mcan_header_t header, u8* stream, u16 size))
s32 MIOS32_CAN_MIDI_SysExStreamCallback_Init(s32 (*callback_sysex_stream)(mios32_mcan_header_t header, u8* stream, u16 size))
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled - accordingly no package in buffer
976,7 → 976,7
//! With return value != 0, APP_MIDI_NotifyPackage() won't get the already processed package.
//! \return < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_CAN_MIDI_PackageCallback_Init(s32 (*direct_package_callback)(mcan_header_t header, mios32_midi_package_t package))
s32 MIOS32_CAN_MIDI_PackageCallback_Init(s32 (*direct_package_callback)(mios32_mcan_header_t header, mios32_midi_package_t package))
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled - accordingly no package in buffer
1069,11 → 1069,11
if(status == 1)return status;
}
mcan_packet_t p;
mios32_mcan_packet_t p;
// Something in the buffer?
if(MIOS32_CAN_RxBufferGet(0, &p.packet) >= 0) {
// usable structure
mcan_header_t header;
mios32_mcan_header_t header;
header.id = p.id;
// exit if CAN port not available
if( !MIOS32_CAN_MIDI_CheckAvailable(header.cable) )
1178,7 → 1178,7
 
} else { // Others messages than Sysex
// prepare header
mcan_header_t header;
mios32_mcan_header_t header;
header.id = p.id;
// data pointer
u8* byte = &p.data.bytes[0];
1225,7 → 1225,7
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
u32 MIOS32_CAN_MIDI_DefaultHeaderInit(mcan_header_t* header)
u32 MIOS32_CAN_MIDI_DefaultHeaderInit(mios32_mcan_header_t* header)
{
#if MIOS32_CAN_NUM == 0
return -1; // all CANs explicitely disabled - accordingly no package in buffer
/branches/mcan/mios32/common/mios32_midi.c
741,7 → 741,7
#if defined(MIOS32_USE_CAN) && defined(MIOS32_USE_CAN_MIDI)
#if defined(MIOS32_CAN_MIDI_SYSEX_DIRECT_STREAM)
if((port & 0xf0) == MCAN0){
mcan_header_t header;
mios32_mcan_header_t header;
MIOS32_CAN_MIDI_DefaultHeaderInit(&header);
header.cable = port & 0x0f;
return MIOS32_CAN_MIDI_SysexSend(header, (u8*)stream, count);