Skip to content

Repair the transmit mailbox (0,1,2) empty interrupt flag not clear BUG #3405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 30, 2016
Merged

Repair the transmit mailbox (0,1,2) empty interrupt flag not clear BUG #3405

merged 2 commits into from
Dec 30, 2016

Conversation

samos2011
Copy link
Contributor

@samos2011 samos2011 commented Dec 9, 2016

Notes:

  • The transmit mailbox empty interrupt flag always keep if IRQ_TX interrupt enabled from can.write(...)

Description

Repair the transmit mailbox (0,1,2) empty interrupt flag not clear BUG

Status

READY

@samos2011 samos2011 changed the title Repair the transmit mailbox (0,1,2) empty interrupt tlag not clear BUG Repair the transmit mailbox (0,1,2) empty interrupt flag not clear BUG Dec 9, 2016
@0xc0170
Copy link
Contributor

0xc0170 commented Dec 9, 2016

cc @bcostm @adustm @LMESTM

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 9, 2016

@adbridge
Copy link
Contributor

@samos2011 bump
cc @bcostm @adustm @LMESTM bump

@samos2011
Copy link
Contributor Author

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 13, 2016

@0xc0170 I already sign https://developer.mbed.org/contributor_agreement/

What's your username on mbed developer page? I can't locate you

@adustm
Copy link
Member

adustm commented Dec 13, 2016

Hello @samos2011,

You could use __HAL_CAN_CLEAR_FLAG macro, for code alignment.

Could you give me more details about the case for which you need to clear TSR ? It looks like we are clearing the IER Transmit Mailbox interrupt (TMEIE) directly. Isn't is sufficient to you ?

Cheers
Armelle

Redress stm32f1xx_hal_can.h header file comment
@samos2011
Copy link
Contributor Author

samos2011 commented Dec 14, 2016

Hello @adustm

a automatically send and receive extend case

#include "CAN.h"
#include "qQueue.h"	// This is first input first output queue, Template class
#include "rtos.h"

namespace mbed{
class qCANMessage :public CANMessage{
public:
	qCANMessage() : CANMessage(){}
	qCANMessage(const qCANMessage& t){
	    len = t.len;
	    type = t.type;
	    format = t.format;
	    id = t.id;
	    memcpy(data, t.data, t.len);
	}
	qCANMessage& operator=(const qCANMessage& t){
	    len = t.len;
	    type = t.type;
	    format = t.format;
	    id = t.id;
	    memcpy(data, t.data, t.len);
	    return *this;
	}
};
// This is automatically send and receive CAN
class qCAN :public CAN{
public:
	queue<qCANMessage> txQueue;
	queue<qCANMessage> rxQueue;	// Receives message here it is

	qCAN(PinName rd, PinName td, int hz = 250000) : CAN(rd, td){
	    frequency(hz);
	    attach(callback(&qCAN::txCallback, this), CAN::TxIrq);
	    attach(callback(&qCAN::rxCallback, this), CAN::RxIrq);
	}
	// return true send failure .@note Send is performed in the background, Don't have to wait
	bool Send(qCANMessage &msg){
	    if (txQueue.IsFull()){
	        Thread::wait(10);
	        if (txQueue.IsFull()){
	            return true;
	        }
	    }
	    txQueue.EnQueue(msg);
	    if (TransmitFlag == false){
	        output()
	        TransmitFlag = true;
	    }
	    return false;
	}

	protected:
	bool TransmitFlag;
	void input(){
	    qCANMessage msg;
	    read(msg);
	    rxQueue.EnQueue(msg);
	}
	void output(){
	    if (txQueue.Count()){ // if queue is not empty
	        qCANMessage msg;
	        txQueue.DeQueue(msg);
	        write(msg);
	    } else{
	        TransmitFlag = false;
	    }
	}
	static void txCallback(qCAN* ptr){
	    ptr->output();
	}
	static void rxCallback(qCAN* ptr){
	    ptr->input();
	}
	};
}

@sg-
Copy link
Contributor

sg- commented Dec 15, 2016

@adustm Look OK?

@samos2011
Copy link
Contributor Author

Hello @0xc0170 My username is samos

@adustm
Copy link
Member

adustm commented Dec 16, 2016

Hello @sg-
The code modification looks OK (setting 1 to the flag is clearing it)
I don't have a use case to test it, but it should not break the other use cases.
I would approve the PR
Cheers

@bridadan
Copy link
Contributor

/morph test

@bridadan
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1284

All builds and test passed!

@mbed-bot
Copy link

[Build 1179]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@0xc0170 0xc0170 merged commit 6598e32 into ARMmbed:master Dec 30, 2016
aisair pushed a commit to aisair/mbed that referenced this pull request Apr 30, 2024
Ports for Upcoming Targets

3459: Target: Add new target UBLOX_EVK_NINA_B1 ARMmbed/mbed-os#3459

Fixes and Changes

3430: Fix ci shield eeprom test ARMmbed/mbed-os#3430
3381: STM32F1 : map ST HAL assert into MBED assert ARMmbed/mbed-os#3381
3389: STM32F2 : map ST HAL assert into MBED assert ARMmbed/mbed-os#3389
3390: STM32F3 : map ST HAL assert into MBED assert ARMmbed/mbed-os#3390
3410: STM32L4 : map ST HAL assert into MBED assert ARMmbed/mbed-os#3410
3422: Enable CAN on DISCO_F303VC ARMmbed/mbed-os#3422
3442: Dev stm i2c f1 ARMmbed/mbed-os#3442
3460: KSDK I2C: Update the return value to match the API documentation change ARMmbed/mbed-os#3460
3472: [RZ/A1H]Fix TTB setting of RO_DATA area ARMmbed/mbed-os#3472
3451: Rename KSDK2 to MCUXpresso. This is the new name of this package ARMmbed/mbed-os#3451
3391: STM32F4 : map ST HAL assert into MBED assert ARMmbed/mbed-os#3391
3454: STM32: Refactor lp_ticker.c + rtc_api.c + sleep.c + rtc_api_hal.h files  ARMmbed/mbed-os#3454
3489: NUCLEO_F103RB - Correct CAN and PWM alternate-functions ARMmbed/mbed-os#3489
3405: Repair the transmit mailbox (0,1,2) empty interrupt flag not clear BUG ARMmbed/mbed-os#3405
3502: MCUXpresso I2C: Handle 0 byte write ARMmbed/mbed-os#3502
3365: [NUC472/M453] Support USB device ARMmbed/mbed-os#3365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants