mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-22 05:11:15 -05:00
Basic data capture works
This commit is contained in:
@@ -65,7 +65,7 @@ DWORD bcm_host_get_peripheral_address(void)
|
||||
char buf[1024];
|
||||
size_t len = sizeof(buf);
|
||||
DWORD address;
|
||||
|
||||
|
||||
if (sysctlbyname("hw.model", buf, &len, NULL, 0) ||
|
||||
strstr(buf, "ARM1176JZ-S") != buf) {
|
||||
// Failed to get CPU model || Not BCM2835
|
||||
@@ -88,7 +88,7 @@ extern uint32_t RPi_IO_Base_Addr;
|
||||
// Core frequency
|
||||
extern uint32_t RPi_Core_Freq;
|
||||
|
||||
#ifdef USE_SEL_EVENT_ENABLE
|
||||
#ifdef USE_SEL_EVENT_ENABLE
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Interrupt control function
|
||||
@@ -460,6 +460,7 @@ void FASTCALL GPIOBUS::Reset()
|
||||
SetMode(PIN_SEL, IN);
|
||||
SetMode(PIN_ATN, IN);
|
||||
SetMode(PIN_ACK, IN);
|
||||
printf("ACK is set to IN\n");
|
||||
SetMode(PIN_RST, IN);
|
||||
|
||||
// Set data bus signals to input
|
||||
@@ -488,6 +489,7 @@ void FASTCALL GPIOBUS::Reset()
|
||||
SetControl(PIN_IND, IND_OUT);
|
||||
SetMode(PIN_SEL, OUT);
|
||||
SetMode(PIN_ATN, OUT);
|
||||
printf("ACK is set to OUT\n");
|
||||
SetMode(PIN_ACK, OUT);
|
||||
SetMode(PIN_RST, OUT);
|
||||
|
||||
@@ -508,6 +510,8 @@ void FASTCALL GPIOBUS::Reset()
|
||||
signals = 0;
|
||||
}
|
||||
|
||||
static DWORD high_bits = 0x0;
|
||||
static DWORD low_bits = 0xFFFFFFFF;
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Bus signal acquisition
|
||||
@@ -517,11 +521,22 @@ DWORD FASTCALL GPIOBUS::Aquire()
|
||||
{
|
||||
signals = *level;
|
||||
|
||||
DWORD prev_high = high_bits;
|
||||
DWORD prev_low = low_bits;
|
||||
|
||||
high_bits |= signals;
|
||||
low_bits &= signals;
|
||||
|
||||
if ((high_bits != prev_high) || (low_bits != prev_low))
|
||||
{
|
||||
printf(" %08lX %08lX\n",high_bits, low_bits);
|
||||
}
|
||||
|
||||
#if SIGNAL_CONTROL_MODE < 2
|
||||
// Invert if negative logic (internal processing is unified to positive logic)
|
||||
signals = ~signals;
|
||||
#endif // SIGNAL_CONTROL_MODE
|
||||
|
||||
|
||||
return signals;
|
||||
}
|
||||
|
||||
@@ -552,36 +567,36 @@ BOOL FASTCALL GPIOBUS::GetBSY()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetBSY(BOOL ast)
|
||||
{
|
||||
// Set BSY signal
|
||||
SetSignal(PIN_BSY, ast);
|
||||
|
||||
if (actmode == TARGET) {
|
||||
if (ast) {
|
||||
// Turn on ACTIVE signal
|
||||
SetControl(PIN_ACT, ACT_ON);
|
||||
|
||||
// Set Target signal to output
|
||||
SetControl(PIN_TAD, TAD_OUT);
|
||||
|
||||
SetMode(PIN_BSY, OUT);
|
||||
SetMode(PIN_MSG, OUT);
|
||||
SetMode(PIN_CD, OUT);
|
||||
SetMode(PIN_REQ, OUT);
|
||||
SetMode(PIN_IO, OUT);
|
||||
} else {
|
||||
// Turn off the ACTIVE signal
|
||||
SetControl(PIN_ACT, ACT_OFF);
|
||||
|
||||
// Set the target signal to input
|
||||
SetControl(PIN_TAD, TAD_IN);
|
||||
|
||||
SetMode(PIN_BSY, IN);
|
||||
SetMode(PIN_MSG, IN);
|
||||
SetMode(PIN_CD, IN);
|
||||
SetMode(PIN_REQ, IN);
|
||||
SetMode(PIN_IO, IN);
|
||||
}
|
||||
}
|
||||
// // Set BSY signal
|
||||
// SetSignal(PIN_BSY, ast);
|
||||
//
|
||||
// if (actmode == TARGET) {
|
||||
// if (ast) {
|
||||
// // Turn on ACTIVE signal
|
||||
// SetControl(PIN_ACT, ACT_ON);
|
||||
//
|
||||
// // Set Target signal to output
|
||||
// SetControl(PIN_TAD, TAD_OUT);
|
||||
//
|
||||
// SetMode(PIN_BSY, OUT);
|
||||
// SetMode(PIN_MSG, OUT);
|
||||
// SetMode(PIN_CD, OUT);
|
||||
// SetMode(PIN_REQ, OUT);
|
||||
// SetMode(PIN_IO, OUT);
|
||||
// } else {
|
||||
// // Turn off the ACTIVE signal
|
||||
// SetControl(PIN_ACT, ACT_OFF);
|
||||
//
|
||||
// // Set the target signal to input
|
||||
// SetControl(PIN_TAD, TAD_IN);
|
||||
//
|
||||
// SetMode(PIN_BSY, IN);
|
||||
// SetMode(PIN_MSG, IN);
|
||||
// SetMode(PIN_CD, IN);
|
||||
// SetMode(PIN_REQ, IN);
|
||||
// SetMode(PIN_IO, IN);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -601,13 +616,13 @@ BOOL FASTCALL GPIOBUS::GetSEL()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetSEL(BOOL ast)
|
||||
{
|
||||
if (actmode == INITIATOR && ast) {
|
||||
// Turn on ACTIVE signal
|
||||
SetControl(PIN_ACT, ACT_ON);
|
||||
}
|
||||
|
||||
// Set SEL signal
|
||||
SetSignal(PIN_SEL, ast);
|
||||
// if (actmode == INITIATOR && ast) {
|
||||
// // Turn on ACTIVE signal
|
||||
// SetControl(PIN_ACT, ACT_ON);
|
||||
// }
|
||||
//
|
||||
// // Set SEL signal
|
||||
// SetSignal(PIN_SEL, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -627,7 +642,7 @@ BOOL FASTCALL GPIOBUS::GetATN()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetATN(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_ATN, ast);
|
||||
// SetSignal(PIN_ATN, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -647,7 +662,7 @@ BOOL FASTCALL GPIOBUS::GetACK()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetACK(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_ACK, ast);
|
||||
//SetSignal(PIN_ACK, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -667,7 +682,7 @@ BOOL FASTCALL GPIOBUS::GetRST()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetRST(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_RST, ast);
|
||||
//SetSignal(PIN_RST, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -687,7 +702,7 @@ BOOL FASTCALL GPIOBUS::GetMSG()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetMSG(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_MSG, ast);
|
||||
//SetSignal(PIN_MSG, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -707,7 +722,7 @@ BOOL FASTCALL GPIOBUS::GetCD()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetCD(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_CD, ast);
|
||||
//SetSignal(PIN_CD, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -805,7 +820,7 @@ BOOL FASTCALL GPIOBUS::GetREQ()
|
||||
//---------------------------------------------------------------------------
|
||||
void FASTCALL GPIOBUS::SetREQ(BOOL ast)
|
||||
{
|
||||
SetSignal(PIN_REQ, ast);
|
||||
// SetSignal(PIN_REQ, ast);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -839,36 +854,36 @@ BYTE FASTCALL GPIOBUS::GetDAT()
|
||||
void FASTCALL GPIOBUS::SetDAT(BYTE dat)
|
||||
{
|
||||
// Write to port
|
||||
#if SIGNAL_CONTROL_MODE == 0
|
||||
DWORD fsel;
|
||||
|
||||
fsel = gpfsel[0];
|
||||
fsel &= tblDatMsk[0][dat];
|
||||
fsel |= tblDatSet[0][dat];
|
||||
if (fsel != gpfsel[0]) {
|
||||
gpfsel[0] = fsel;
|
||||
gpio[GPIO_FSEL_0] = fsel;
|
||||
}
|
||||
|
||||
fsel = gpfsel[1];
|
||||
fsel &= tblDatMsk[1][dat];
|
||||
fsel |= tblDatSet[1][dat];
|
||||
if (fsel != gpfsel[1]) {
|
||||
gpfsel[1] = fsel;
|
||||
gpio[GPIO_FSEL_1] = fsel;
|
||||
}
|
||||
|
||||
fsel = gpfsel[2];
|
||||
fsel &= tblDatMsk[2][dat];
|
||||
fsel |= tblDatSet[2][dat];
|
||||
if (fsel != gpfsel[2]) {
|
||||
gpfsel[2] = fsel;
|
||||
gpio[GPIO_FSEL_2] = fsel;
|
||||
}
|
||||
#else
|
||||
gpio[GPIO_CLR_0] = tblDatMsk[dat];
|
||||
gpio[GPIO_SET_0] = tblDatSet[dat];
|
||||
#endif // SIGNAL_CONTROL_MODE
|
||||
//#if SIGNAL_CONTROL_MODE == 0
|
||||
// DWORD fsel;
|
||||
//
|
||||
// fsel = gpfsel[0];
|
||||
// fsel &= tblDatMsk[0][dat];
|
||||
// fsel |= tblDatSet[0][dat];
|
||||
// if (fsel != gpfsel[0]) {
|
||||
// gpfsel[0] = fsel;
|
||||
// gpio[GPIO_FSEL_0] = fsel;
|
||||
// }
|
||||
//
|
||||
// fsel = gpfsel[1];
|
||||
// fsel &= tblDatMsk[1][dat];
|
||||
// fsel |= tblDatSet[1][dat];
|
||||
// if (fsel != gpfsel[1]) {
|
||||
// gpfsel[1] = fsel;
|
||||
// gpio[GPIO_FSEL_1] = fsel;
|
||||
// }
|
||||
//
|
||||
// fsel = gpfsel[2];
|
||||
// fsel &= tblDatMsk[2][dat];
|
||||
// fsel |= tblDatSet[2][dat];
|
||||
// if (fsel != gpfsel[2]) {
|
||||
// gpfsel[2] = fsel;
|
||||
// gpio[GPIO_FSEL_2] = fsel;
|
||||
// }
|
||||
//#else
|
||||
// gpio[GPIO_CLR_0] = tblDatMsk[dat];
|
||||
// gpio[GPIO_SET_0] = tblDatSet[dat];
|
||||
//#endif // SIGNAL_CONTROL_MODE
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -1155,7 +1170,7 @@ int FASTCALL GPIOBUS::SendHandShake(BYTE *buf, int count)
|
||||
}
|
||||
|
||||
// Already waiting for REQ assertion
|
||||
|
||||
|
||||
// Assert the ACK signal
|
||||
SetSignal(PIN_ACK, ON);
|
||||
|
||||
@@ -1399,7 +1414,7 @@ void FASTCALL GPIOBUS::SetMode(int pin, int mode)
|
||||
gpio[index] = data;
|
||||
gpfsel[index] = data;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Get input signal value
|
||||
@@ -1409,7 +1424,7 @@ BOOL FASTCALL GPIOBUS::GetSignal(int pin)
|
||||
{
|
||||
return (signals >> pin) & 1;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Set output signal value
|
||||
|
||||
Reference in New Issue
Block a user