diff --git a/tas2557.c b/tas2557.c
index 1779380caa08eecfb2c7eb99905e6358ae89e860..d55b81366335867e871dd6f5424ebd0ef8423123 100755 (executable)
--- a/tas2557.c
+++ b/tas2557.c
return pData[0];
}
-uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg)
+uint32_t tas2557_coeff_read(uint32_t reg)
{
+ uint8_t nbook = TAS2557_BOOK_ID(reg);
+ uint8_t npage = TAS2557_PAGE_ID(reg);
+ uint8_t nreg = TAS2557_PAGE_REG(reg);
unsigned char pPageZero[] = {0x00, 0x00};
- unsigned char pBook[] = {0x7F, book};
- unsigned char pPage[] = {0x00, page};
- unsigned char pData[] = {reg, 0x00, 0x00, 0x00, 0x00};
+ unsigned char pBook[] = {0x7F, nbook};
+ unsigned char pPage[] = {0x00, npage};
+ unsigned char pData[] = {nreg, 0x00, 0x00, 0x00, 0x00};
tas2557_check_node();
return 0;
}
-void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
+#define TAS2557_mCDSP_SWAP_REG TAS2557_REG(0x8c, 0x19, 0x7c)
+#define TAS2557_uCDSP_SWAP_REG TAS2557_REG(0x00, 0x35, 0x2c)
+
+void tas2557_coeff_write(uint32_t reg, uint32_t data)
{
unsigned int nByte;
+ uint8_t nbook, npage, nreg;
- if (gBinFile) // if the bin file is open, write the coefficients to the bin file
- {
- if(gnDev == gnDevA){
+ nbook = TAS2557_BOOK_ID(reg);
+ npage = TAS2557_PAGE_ID(reg);
+ nreg = TAS2557_PAGE_REG(reg);
+
+ // if the bin file is open, write the coefficients to the bin file
+ if (gBinFile) {
+ if (gnDev == gnDevA) {
unsigned int index = gnDevABlockIndex*4;
+
gpDevABlock[index] = 0;
gpDevABlock[index + 1] = 4;
gpDevABlock[index + 2] = 0x85;
- gpDevABlock[index + 4] = book;
- gpDevABlock[index + 5] = page;
- gpDevABlock[index + 6] = reg;
-
+ gpDevABlock[index + 4] = nbook;
+ gpDevABlock[index + 5] = npage;
+ gpDevABlock[index + 6] = nreg;
+
for (nByte = 0; nByte < 4; nByte++)
- {
gpDevABlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
- }
-
- gnDevABlockIndex += 3;
- }
- else if(gnDev == gnDevB)
- {
+
+ gnDevABlockIndex += 3;
+ } else if (gnDev == gnDevB) {
unsigned int index = gnDevBBlockIndex*4;
+
gpDevBBlock[index] = 0;
gpDevBBlock[index + 1] = 4;
gpDevBBlock[index + 2] = 0x85;
- gpDevBBlock[index + 4] = book;
- gpDevBBlock[index + 5] = page;
- gpDevBBlock[index + 6] = reg;
-
+ gpDevBBlock[index + 4] = nbook;
+ gpDevBBlock[index + 5] = npage;
+ gpDevBBlock[index + 6] = nreg;
+
for (nByte = 0; nByte < 4; nByte++)
- {
gpDevBBlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
- }
-
- gnDevBBlockIndex += 3;
- }
- }
- else
- {
+
+ gnDevBBlockIndex += 3;
+ }
+ } else {
unsigned char pPageZero[] = {0x00, 0x00};
- unsigned char pBook[] = {0x7F, book};
- unsigned char pPage[] = {0x00, page};
- unsigned char pData[] = {reg, (data & 0xFF000000) >> 24, (data & 0x00FF0000) >> 16, (data & 0x0000FF00) >> 8, data & 0x000000FF};
+ unsigned char pBook[] = {0x7F, nbook};
+ unsigned char pPage[] = {0x00, npage};
+ unsigned char pData[] = {nreg, (data & 0xFF000000) >> 24, (data & 0x00FF0000) >> 16, (data & 0x0000FF00) >> 8, data & 0x000000FF};
tas2557_check_node();
@@ -203,10 +208,10 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
write(gTILoad, pPage, 2);
write(gTILoad, pData, 5);
- pBook[1] = 0x8C;
- pPage[1] = 0x19;
+ pBook[1] = TAS2557_BOOK_ID(TAS2557_mCDSP_SWAP_REG);
+ pPage[1] = TAS2557_PAGE_ID(TAS2557_mCDSP_SWAP_REG);
- pData[0] = 0x7C;
+ pData[0] = TAS2557_PAGE_REG(TAS2557_mCDSP_SWAP_REG);
pData[1] = 0x00;
pData[2] = 0x00;
pData[3] = 0x00;
@@ -217,10 +222,10 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
write(gTILoad, pPage, 2);
write(gTILoad, pData, 5);
- pBook[1] = 0x00;
- pPage[1] = 0x35;
+ pBook[1] = TAS2557_BOOK_ID(TAS2557_uCDSP_SWAP_REG);;
+ pPage[1] = TAS2557_PAGE_ID(TAS2557_uCDSP_SWAP_REG);
- pData[0] = 0x2c;
+ pData[0] = TAS2557_PAGE_REG(TAS2557_uCDSP_SWAP_REG);
pData[1] = 0x00;
pData[2] = 0x00;
pData[3] = 0x00;
unsigned int nCommands;
unsigned char pCommit[] = {
0x00, 0x04, 0x85, 0x00,
- 0x8C, 0x19, 0x7C, 0x00,
+ TAS2557_BOOK_ID(TAS2557_mCDSP_SWAP_REG), TAS2557_PAGE_ID(TAS2557_mCDSP_SWAP_REG), TAS2557_PAGE_REG(TAS2557_mCDSP_SWAP_REG), 0x00,
0x00, 0x00, 0x01, 0x00,
0x00, 0x04, 0x85, 0x00,
- 0x00, 0x35, 0x2c, 0x00,
+ TAS2557_BOOK_ID(TAS2557_uCDSP_SWAP_REG), TAS2557_PAGE_ID(TAS2557_uCDSP_SWAP_REG), TAS2557_PAGE_REG(TAS2557_uCDSP_SWAP_REG), 0x00,
0x00, 0x00, 0x01, 0x00
};