mirror of
https://github.com/brmlab/edubrm.git
synced 2025-06-08 12:53:59 +02:00
add SSP commands
This commit is contained in:
parent
1e2e2587bb
commit
cb8ea5c0e5
5 changed files with 36 additions and 8 deletions
|
@ -46,7 +46,13 @@ void SetOutReport (uint8_t dst[], uint32_t length)
|
|||
case 'D':
|
||||
freq = dst[1] + (dst[2]<<8) + (dst[3]<<16) + (dst[4]<<24);
|
||||
LPC_GPIO0->MASKED_ACCESS[1<<2] &= ((0<<2) | ~(1<<2)); // set chipselect to 0
|
||||
// TODO: set SPI commands
|
||||
freq = 0xFFFFFFFF/50000000*freq;
|
||||
SSPSend2(0xF8, 0x00);
|
||||
SSPSend2(0x33, ((freq & 0xFF000000) >> 24));
|
||||
SSPSend2(0x22, ((freq & 0x00FF0000) >> 16));
|
||||
SSPSend2(0x31, ((freq & 0x0000FF00) >> 8));
|
||||
SSPSend2(0x20, ((freq & 0x000000FF)));
|
||||
SSPSend2(0xC0, 0x00);
|
||||
LPC_GPIO0->MASKED_ACCESS[1<<2] |= (0<<2); // set chipselect to 1
|
||||
break;
|
||||
case 'm':
|
||||
|
@ -58,7 +64,20 @@ void SetOutReport (uint8_t dst[], uint32_t length)
|
|||
} else {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<2] &= ((0<<2) | ~(1<<2)); // set chipselect to 0
|
||||
}
|
||||
// TODO: set opamp (which) on channel (chan) with gain (gain) via SPI
|
||||
// set channel
|
||||
SSPSend2(0x41, chan); // 000 - ch#1, 101 - ch#6
|
||||
if (which == 1) {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<3] |= (0<<3); // set chipselect to 1
|
||||
} else {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<2] |= (0<<2); // set chipselect to 1
|
||||
}
|
||||
if (which == 1) {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<3] &= ((0<<3) | ~(1<<3)); // set chipselect to 0
|
||||
} else {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<2] &= ((0<<2) | ~(1<<2)); // set chipselect to 0
|
||||
}
|
||||
// set gain
|
||||
SSPSend2(0x40, gain); // 000 - 1, 111 - 32
|
||||
if (which == 1) {
|
||||
LPC_GPIO3->MASKED_ACCESS[1<<3] |= (0<<3); // set chipselect to 1
|
||||
} else {
|
||||
|
@ -119,7 +138,7 @@ void PinInit() {
|
|||
LPC_IOCON->PIO3_1 |= 0x00;
|
||||
LPC_GPIO2->DIR |= (1<<8) | (1<<9) | (1<<10) | (1<<11);
|
||||
LPC_GPIO3->DIR |= (1<<0) | (1<<1);
|
||||
SwitchesState(0);
|
||||
SwitchesSetup(0);
|
||||
|
||||
//set chip select pins function
|
||||
LPC_IOCON->PIO0_2 &= ~0x07; // DDS
|
||||
|
|
|
@ -5,4 +5,4 @@ void EnablePWM2(uint16_t period, uint16_t duty);
|
|||
void PinDir(uint16_t mask);
|
||||
void PinState(uint8_t which, uint8_t state);
|
||||
void EduInit();
|
||||
void SwitchesSetup(uint8_t states);
|
||||
void SwitchesSetup(uint8_t states);
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
#include "LPC13xx.h"
|
||||
#include "ssp.h"
|
||||
|
||||
void SSPSend2(const uint8_t a, const uint8_t b)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
buf[0] = a;
|
||||
buf[1] = b;
|
||||
SSPSend(buf, 2);
|
||||
}
|
||||
|
||||
void SSPSend( const uint8_t *buf, uint32_t Length )
|
||||
{
|
||||
uint32_t i;
|
||||
|
|
|
@ -110,6 +110,7 @@ extern void SSP_IRQHandler (void);
|
|||
extern void SSPInit( void );
|
||||
extern void SSPSend( const uint8_t *Buf, uint32_t Length );
|
||||
extern void SSPReceive( uint8_t *buf, uint32_t Length );
|
||||
extern void SSPSend2(const uint8_t a, const uint8_t b);
|
||||
|
||||
#endif /* __SSP_H__ */
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -72,14 +72,14 @@ class ModuleDebugWidget(QWidget):
|
|||
|
||||
@pyqtSlot()
|
||||
def on_comboAMP1_changed(self):
|
||||
c = self.ui.comboAMP1c.currentIndex() + 1
|
||||
g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP1g.currentIndex()]
|
||||
c = self.ui.comboAMP1c.currentIndex()
|
||||
g = self.ui.comboAMP1g.currentIndex()
|
||||
self.dev.opamp(1, c, g)
|
||||
|
||||
@pyqtSlot()
|
||||
def on_comboAMP2_changed(self):
|
||||
c = self.ui.comboAMP2c.currentIndex() + 1
|
||||
g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP2g.currentIndex()]
|
||||
c = self.ui.comboAMP2c.currentIndex()
|
||||
g = self.ui.comboAMP2g.currentIndex()
|
||||
self.dev.opamp(2, c, g)
|
||||
|
||||
@pyqtSlot()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue