...
 
Commits (3)
This diff is collapsed.
......@@ -677,18 +677,24 @@ int i2c_stop(lms_device_t* lms)
return 0;
}
unsigned char i2c_rx(lms_device_t* lms, char ack)
int i2c_rx(lms_device_t* lms, char ack, unsigned char* d)
{
char x, d = 0;
char x = 0;
i2c_setVal(lms, GPIO_SDA, 1);
for (x = 0; x<8; x++) {
d <<= 1;
(*d) <<= 1;
int attempt = 0;
do {
i2c_setVal(lms, GPIO_SCL, 1);
attempt++;
if (attempt > 100) { // Is this limit OK?
return RFE_ERROR_COMM;
}
} while (i2c_getVal(lms, GPIO_SCL) == 0); // wait for any SCL clock stretching
i2c_dly();
if (i2c_getVal(lms, GPIO_SDA)) d |= 1;
if (i2c_getVal(lms, GPIO_SDA)) (*d) |= 1;
i2c_setVal(lms, GPIO_SCL, 0);
}
if (ack) i2c_setVal(lms, GPIO_SDA, 0);
......@@ -697,7 +703,8 @@ unsigned char i2c_rx(lms_device_t* lms, char ack)
i2c_dly(); // send (N)ACK bit
i2c_setVal(lms, GPIO_SCL, 0);
i2c_setVal(lms, GPIO_SDA, 1);
return d;
// return d;
return RFE_SUCCESS;
}
int i2c_tx(lms_device_t* lms, unsigned char d)
......@@ -753,7 +760,9 @@ int i2c_read_buffer(lms_device_t* lms, unsigned char* c, int size) {
char ack = 1;
if (i == (size - 1))
ack = 0;
c[i] = i2c_rx(lms, ack);
int res = i2c_rx(lms, ack, &(c[i]));
if (res != RFE_SUCCESS)
return RFE_ERROR_COMM;
}
i2c_stop(lms); // send stop sequence
return i;
......
......@@ -201,7 +201,7 @@ extern "C" {
int i2c_getVal(lms_device_t* lms, int bitGPIO);
int i2c_start(lms_device_t* lms);
int i2c_stop(lms_device_t* lms);
unsigned char i2c_rx(lms_device_t* lms, char ack);
int i2c_rx(lms_device_t* lms, char ack, unsigned char* d);
int i2c_tx(lms_device_t* lms, unsigned char d);
int i2c_write_buffer(lms_device_t* lms, unsigned char* c, int size);
int i2c_read_buffer(lms_device_t* lms, unsigned char* c, int size);
......
......@@ -197,14 +197,6 @@ limeRFE_view::limeRFE_view( wxWindow* parent, wxWindowID id, const wxString& tit
bSizer7->Fit( m_panel172 );
fgSizer2->Add( m_panel172, 1, wxALL|wxEXPAND, 2 );
wxFlexGridSizer* fgSizer11;
fgSizer11 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer11->SetFlexibleDirection( wxBOTH );
fgSizer11->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fgSizer2->Add( fgSizer11, 1, wxEXPAND, 5 );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 0, 0, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
......@@ -716,18 +708,36 @@ limeRFE_view::limeRFE_view( wxWindow* parent, wxWindowID id, const wxString& tit
fgSizer2->Add( fgSizer1, 0, wxEXPAND, 2 );
wxFlexGridSizer* fgSizer301;
fgSizer301 = new wxFlexGridSizer( 1, 1, 0, 0 );
fgSizer301->SetFlexibleDirection( wxBOTH );
fgSizer301->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_panel173 = new wxPanel( pnlMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL );
wxFlexGridSizer* fgSizer17;
fgSizer17 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer17->AddGrowableCol( 0 );
fgSizer17->SetFlexibleDirection( wxBOTH );
fgSizer17->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
txtMessageField = new wxTextCtrl( m_panel173, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
txtMessageField->SetMinSize( wxSize( -1,100 ) );
fgSizer2->Add( fgSizer301, 1, wxEXPAND, 5 );
fgSizer17->Add( txtMessageField, 0, wxEXPAND, 5 );
m_panel18 = new wxPanel( m_panel173, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer24;
bSizer24 = new wxBoxSizer( wxVERTICAL );
btnClearMessages = new wxButton( m_panel18, wxID_ANY, wxT("Clear"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer24->Add( btnClearMessages, 0, 0, 5 );
m_panel18->SetSizer( bSizer24 );
m_panel18->Layout();
bSizer24->Fit( m_panel18 );
fgSizer17->Add( m_panel18, 0, wxEXPAND, 5 );
txtMessageField = new wxTextCtrl( pnlMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
txtMessageField->SetMinSize( wxSize( -1,100 ) );
fgSizer2->Add( txtMessageField, 0, wxEXPAND, 5 );
m_panel173->SetSizer( fgSizer17 );
m_panel173->Layout();
fgSizer17->Fit( m_panel173 );
fgSizer2->Add( m_panel173, 1, wxEXPAND, 5 );
pnlMain->SetSizer( fgSizer2 );
......@@ -772,6 +782,7 @@ limeRFE_view::limeRFE_view( wxWindow* parent, wxWindowID id, const wxString& tit
btnConfigure->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnConfigure ), NULL, this );
btnReadADC->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnReadADC ), NULL, this );
btnCalibrate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnCalibrate ), NULL, this );
btnClearMessages->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnClearMessages ), NULL, this );
}
limeRFE_view::~limeRFE_view()
......@@ -806,5 +817,6 @@ limeRFE_view::~limeRFE_view()
btnConfigure->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnConfigure ), NULL, this );
btnReadADC->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnReadADC ), NULL, this );
btnCalibrate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnCalibrate ), NULL, this );
btnClearMessages->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( limeRFE_view::OnbtnClearMessages ), NULL, this );
}
......@@ -118,7 +118,10 @@ class limeRFE_view : public wxFrame
wxStaticText* m_staticText1021;
wxTextCtrl* tcRLCalibrate;
wxStaticText* m_staticText1221;
wxPanel* m_panel173;
wxTextCtrl* txtMessageField;
wxPanel* m_panel18;
wxButton* btnClearMessages;
// Virtual event handlers, overide them in your derived class
virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); }
......@@ -149,6 +152,7 @@ class limeRFE_view : public wxFrame
virtual void OnbtnConfigure( wxCommandEvent& event ) { event.Skip(); }
virtual void OnbtnReadADC( wxCommandEvent& event ) { event.Skip(); }
virtual void OnbtnCalibrate( wxCommandEvent& event ) { event.Skip(); }
virtual void OnbtnClearMessages( wxCommandEvent& event ) { event.Skip(); }
public:
......
......@@ -1110,4 +1110,8 @@ void limeRFE_wxgui::OnQuit(wxCommandEvent& event) {
void limeRFE_wxgui::OncbEnableSWR(wxCommandEvent& event) {
configured = false;
UpdateRFEForm();
}
void limeRFE_wxgui::OnbtnClearMessages(wxCommandEvent& event) {
txtMessageField->Clear();
}
\ No newline at end of file
......@@ -113,6 +113,8 @@ class limeRFE_wxgui : public limeRFE_view
void FindChannelChoices(int type, wxArrayString* channelItems);
void OnbtnClearMessages(wxCommandEvent& event);
public:
/** Constructor */
limeRFE_wxgui(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString &title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long styles = 0);
......