Skip to content

Commit 04a7962

Browse files
author
Donatien Garnier
committed
Expose Event Queue to NFCEEPROMDriver
1 parent 51f5529 commit 04a7962

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

features/nfc/nfc/NFCEEPROM.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class NFCEEPROM : public NFCTarget, public NFCEEPROMDriver::Delegate {
9090
virtual void on_size_written(bool success);
9191
virtual void on_size_read(bool success, size_t size);
9292
virtual void on_bytes_erased(size_t count);
93-
virtual void on_event();
9493

9594
void handle_error(nfc_err_t ret);
9695
void continue_write();
@@ -117,7 +116,6 @@ class NFCEEPROM : public NFCTarget, public NFCEEPROMDriver::Delegate {
117116
};
118117

119118
NFCEEPROMDriver *_driver;
120-
events::EventQueue *_queue;
121119
bool _initialized;
122120

123121
nfc_eeprom_operation_t _current_op;

features/nfc/nfc/NFCEEPROMDriver.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ class NFCEEPROMDriver {
9696
* @param[in] count number of bytes actually erased
9797
*/
9898
virtual void on_bytes_erased(size_t count) = 0;
99-
100-
/**
101-
* Signal the user that the process_events() need to be called
102-
*
103-
* @note this function can be called in interrupt context
104-
*/
105-
virtual void on_event() = 0;
10699
};
107100

108101
/**
@@ -113,15 +106,17 @@ class NFCEEPROMDriver {
113106
void set_delegate(Delegate *delegate);
114107

115108
/**
116-
* Reset and initialize the EEPROM.
117-
* This method should complete synchronously.
109+
* Set the event queue that will be used to schedule event handling
110+
*
111+
* @param[in] queue the queue instance to use
118112
*/
119-
virtual void reset() = 0;
113+
void set_event_queue(EventQueue *queue);
120114

121115
/**
122-
* Process events raised by the driver in interrupt context.
116+
* Reset and initialize the EEPROM.
117+
* This method should complete synchronously.
123118
*/
124-
virtual void process_events();
119+
virtual void reset() = 0;
125120

126121
/**
127122
* Get the maximum memory size addressable by the EEPROM.
@@ -185,9 +180,11 @@ class NFCEEPROMDriver {
185180

186181
protected:
187182
Delegate *delegate();
183+
EventQueue *event_queue();
188184

189185
private:
190186
Delegate *_delegate;
187+
EventQueue *_event_queue;
191188
};
192189

193190
/**

features/nfc/source/nfc/NFCEEPROM.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ using namespace mbed;
2121
using namespace mbed::nfc;
2222

2323
NFCEEPROM(NFCEEPROMDriver *driver, events::EventQueue *queue, uint8_t *ndef_buffer, size_t ndef_buffer_sz) : NFCTarget(ndef_buffer, ndef_buffer_sz)
24-
_driver(driver), _queue(queue), _initialized(false), _current_op(nfc_eeprom_idle), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
24+
_driver(driver), _initialized(false), _current_op(nfc_eeprom_idle), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
2525
{
2626
_driver->set_delegate(this);
27+
_driver->set_event_queue(queue);
2728
}
2829

2930
nfc_err_t NFCEEPROM::initialize()
@@ -349,12 +350,6 @@ void NFCEEPROM::on_bytes_erased(size_t count)
349350
}
350351
}
351352

352-
void NFCEEPROM::on_event()
353-
{
354-
// Just schedule a task on event queue
355-
_queue->call(_driver, NFCEEPROMDriver::process_events);
356-
}
357-
358353
void NFCEEPROM::continue_write()
359354
{
360355
if (ac_buffer_reader_readable(&_ndef_buffer_reader) > 0) {

features/nfc/source/nfc/NFCEEPROMDriver.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
using namespace mbed;
2020
using namespace mbed::nfc;
2121

22-
NFCEEPROMDriver::NFCEEPROMDriver() : _delegate(NULL)
22+
NFCEEPROMDriver::NFCEEPROMDriver() : _delegate(NULL), _event_queue(NULL)
2323
{
2424

2525
}
@@ -28,3 +28,18 @@ void NFCEEPROMDriver::set_delegate(Delegate *delegate)
2828
{
2929
_delegate = delegate;
3030
}
31+
32+
void NFCEEPROMDriver::set_event_queue(EventQueue *queue)
33+
{
34+
_event_queue = queue;
35+
}
36+
37+
Delegate *NFCEEPROMDriver::delegate()
38+
{
39+
return _delegate;
40+
}
41+
42+
EventQueue *NFCEEPROMDriver::event_queue()
43+
{
44+
return _event_queue;
45+
}

0 commit comments

Comments
 (0)