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':
|
case 'D':
|
||||||
freq = dst[1] + (dst[2]<<8) + (dst[3]<<16) + (dst[4]<<24);
|
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
|
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
|
LPC_GPIO0->MASKED_ACCESS[1<<2] |= (0<<2); // set chipselect to 1
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
|
@ -58,7 +64,20 @@ void SetOutReport (uint8_t dst[], uint32_t length)
|
||||||
} else {
|
} else {
|
||||||
LPC_GPIO3->MASKED_ACCESS[1<<2] &= ((0<<2) | ~(1<<2)); // set chipselect to 0
|
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) {
|
if (which == 1) {
|
||||||
LPC_GPIO3->MASKED_ACCESS[1<<3] |= (0<<3); // set chipselect to 1
|
LPC_GPIO3->MASKED_ACCESS[1<<3] |= (0<<3); // set chipselect to 1
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,7 +138,7 @@ void PinInit() {
|
||||||
LPC_IOCON->PIO3_1 |= 0x00;
|
LPC_IOCON->PIO3_1 |= 0x00;
|
||||||
LPC_GPIO2->DIR |= (1<<8) | (1<<9) | (1<<10) | (1<<11);
|
LPC_GPIO2->DIR |= (1<<8) | (1<<9) | (1<<10) | (1<<11);
|
||||||
LPC_GPIO3->DIR |= (1<<0) | (1<<1);
|
LPC_GPIO3->DIR |= (1<<0) | (1<<1);
|
||||||
SwitchesState(0);
|
SwitchesSetup(0);
|
||||||
|
|
||||||
//set chip select pins function
|
//set chip select pins function
|
||||||
LPC_IOCON->PIO0_2 &= ~0x07; // DDS
|
LPC_IOCON->PIO0_2 &= ~0x07; // DDS
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
#include "LPC13xx.h"
|
#include "LPC13xx.h"
|
||||||
#include "ssp.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 )
|
void SSPSend( const uint8_t *buf, uint32_t Length )
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
|
@ -110,6 +110,7 @@ extern void SSP_IRQHandler (void);
|
||||||
extern void SSPInit( void );
|
extern void SSPInit( void );
|
||||||
extern void SSPSend( const uint8_t *Buf, uint32_t Length );
|
extern void SSPSend( const uint8_t *Buf, uint32_t Length );
|
||||||
extern void SSPReceive( 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__ */
|
#endif /* __SSP_H__ */
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
|
@ -72,14 +72,14 @@ class ModuleDebugWidget(QWidget):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_comboAMP1_changed(self):
|
def on_comboAMP1_changed(self):
|
||||||
c = self.ui.comboAMP1c.currentIndex() + 1
|
c = self.ui.comboAMP1c.currentIndex()
|
||||||
g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP1g.currentIndex()]
|
g = self.ui.comboAMP1g.currentIndex()
|
||||||
self.dev.opamp(1, c, g)
|
self.dev.opamp(1, c, g)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_comboAMP2_changed(self):
|
def on_comboAMP2_changed(self):
|
||||||
c = self.ui.comboAMP2c.currentIndex() + 1
|
c = self.ui.comboAMP2c.currentIndex()
|
||||||
g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP2g.currentIndex()]
|
g = self.ui.comboAMP2g.currentIndex()
|
||||||
self.dev.opamp(2, c, g)
|
self.dev.opamp(2, c, g)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue