EE445M RTOS
Taken at the University of Texas Spring 2015
epi.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // epi.c - Driver for the EPI module.
4 //
5 // Copyright (c) 2008-2014 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #include <stdbool.h>
41 #include <stdint.h>
42 #include "inc/hw_epi.h"
43 #include "inc/hw_ints.h"
44 #include "inc/hw_memmap.h"
45 #include "inc/hw_sysctl.h"
46 #include "inc/hw_types.h"
47 #include "driverlib/debug.h"
48 #include "driverlib/epi.h"
49 #include "driverlib/interrupt.h"
50 
51 //*****************************************************************************
52 //
55 //
56 //*****************************************************************************
57 
58 //*****************************************************************************
59 //
60 // Helper masks for chip select configuration options.
61 //
62 //*****************************************************************************
63 #define EPI_HB8_CS_MASK (EPI_HB8_MODE_FIFO | EPI_HB8_RDWAIT_3 | \
64  EPI_HB8_WRWAIT_3 | EPI_HB8_RDHIGH | \
65  EPI_HB8_WRHIGH | EPI_HB8_ALE_HIGH)
66 
67 #define EPI_HB16_CS_MASK (EPI_HB8_CS_MASK | EPI_HB16_BURST_TRAFFIC)
68 
69 //*****************************************************************************
70 //
71 // Ensure that erratum workaround inline functions have a public version
72 // available in exactly one object module (this one).
73 //
74 //*****************************************************************************
75 
76 //*****************************************************************************
77 //
98 //
99 //*****************************************************************************
100 extern void EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value);
101 
102 //*****************************************************************************
103 //
123 //
124 //*****************************************************************************
125 extern uint32_t EPIWorkaroundWordRead(uint32_t *pui32Addr);
126 
127 //*****************************************************************************
128 //
149 //
150 //*****************************************************************************
151 extern void EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value);
152 
153 //*****************************************************************************
154 //
174 //
175 //*****************************************************************************
176 extern uint16_t EPIWorkaroundHWordRead(uint16_t *pui16Addr);
177 
178 //*****************************************************************************
179 //
200 //
201 //*****************************************************************************
202 extern void EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value);
203 
204 //*****************************************************************************
205 //
225 //
226 //*****************************************************************************
227 extern uint8_t EPIWorkaroundByteRead(uint8_t *pui8Addr);
228 
229 //*****************************************************************************
230 //
249 //
250 //*****************************************************************************
251 void
252 EPIModeSet(uint32_t ui32Base, uint32_t ui32Mode)
253 {
254  //
255  // Check the arguments.
256  //
257  ASSERT(ui32Base == EPI0_BASE);
258  ASSERT((ui32Mode == EPI_MODE_GENERAL) ||
259  (ui32Mode == EPI_MODE_SDRAM) ||
260  (ui32Mode == EPI_MODE_HB8) ||
261  (ui32Mode == EPI_MODE_HB16) ||
262  (ui32Mode == EPI_MODE_DISABLE));
263 
264  //
265  // Write the mode word to the register.
266  //
267  HWREG(ui32Base + EPI_O_CFG) = ui32Mode;
268 }
269 
270 //*****************************************************************************
271 //
295 //
296 //*****************************************************************************
297 void
298 EPIDividerSet(uint32_t ui32Base, uint32_t ui32Divider)
299 {
300  //
301  // Check the arguments.
302  //
303  ASSERT(ui32Base == EPI0_BASE);
304 
305  //
306  // Write the divider value to the register.
307  //
308  HWREG(ui32Base + EPI_O_BAUD) = ui32Divider;
309 }
310 
311 //*****************************************************************************
312 //
336 //
337 //*****************************************************************************
338 void
339 EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS,
340  uint32_t ui32Divider)
341 {
342  uint32_t ui32Reg;
343 
344  //
345  // Check the arguments.
346  //
347  ASSERT(ui32Base == EPI0_BASE);
348  ASSERT(ui32CS < 4);
349 
350  //
351  // Write the divider value to the register bitfield.
352  //
353  if(ui32CS < 2)
354  {
355  ui32Reg = HWREG(ui32Base + EPI_O_BAUD) & ~(0xffff << (16 * ui32CS));
356  ui32Reg |= ((ui32Divider & 0xffff) << (16 * ui32CS));
357  HWREG(ui32Base + EPI_O_BAUD) = ui32Reg;
358  }
359  else
360  {
361  ui32Reg = (HWREG(ui32Base + EPI_O_BAUD2) &
362  ~(0xffff << (16 * (ui32CS - 2))));
363  ui32Reg |= ((ui32Divider & 0xffff) << (16 * (ui32CS - 2)));
364  HWREG(ui32Base + EPI_O_BAUD2) = ui32Reg;
365  }
366 }
367 
368 //*****************************************************************************
369 //
388 //
389 //*****************************************************************************
390 void
391 EPIDMATxCount(uint32_t ui32Base, uint32_t ui32Count)
392 {
393  //
394  // Check the arguments.
395  //
396  ASSERT(ui32Base == EPI0_BASE);
397  ASSERT(ui32Count <= 1024);
398 
399  //
400  // Assign the DMA TX count value provided.
401  //
402  HWREG(ui32Base + EPI_O_DMATXCNT) = ui32Count & 0xffff;
403 }
404 
405 //*****************************************************************************
406 //
441 //
442 //*****************************************************************************
443 void
444 EPIConfigSDRAMSet(uint32_t ui32Base, uint32_t ui32Config,
445  uint32_t ui32Refresh)
446 {
447  //
448  // Check the arguments.
449  //
450  ASSERT(ui32Base == EPI0_BASE);
451  ASSERT(ui32Refresh < 2048);
452 
453  //
454  // Fill in the refresh count field of the configuration word.
455  //
456  ui32Config &= ~EPI_SDRAMCFG_RFSH_M;
457  ui32Config |= ui32Refresh << EPI_SDRAMCFG_RFSH_S;
458 
459  //
460  // Write the SDRAM configuration register.
461  //
462  HWREG(ui32Base + EPI_O_SDRAMCFG) = ui32Config;
463 }
464 
465 //*****************************************************************************
466 //
566 //
567 //*****************************************************************************
568 void
569 EPIConfigHB8Set(uint32_t ui32Base, uint32_t ui32Config,
570  uint32_t ui32MaxWait)
571 {
572  //
573  // Check the arguments.
574  //
575  ASSERT(ui32Base == EPI0_BASE);
576  ASSERT(ui32MaxWait < 256);
577 
578  //
579  // Determine the CS and word access modes.
580  //
581  HWREG(ui32Base + EPI_O_HB8CFG2) =
582  ((ui32Config & EPI_HB8_CSBAUD) ? EPI_HB8CFG2_CSBAUD : 0) |
583  ((ui32Config & EPI_HB8_CSCFG_MASK) << 15);
584 
585  //
586  // Fill in the max wait field of the configuration word.
587  //
588  ui32Config &= ~EPI_HB8CFG_MAXWAIT_M;
589  ui32Config |= ui32MaxWait << EPI_HB8CFG_MAXWAIT_S;
590 
591  //
592  // Write the main HostBus8 configuration register.
593  //
594  HWREG(ui32Base + EPI_O_HB8CFG) = ui32Config;
595 }
596 
597 //*****************************************************************************
598 //
709 //
710 //*****************************************************************************
711 void
712 EPIConfigHB16Set(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32MaxWait)
713 {
714  //
715  // Check the arguments.
716  //
717  ASSERT(ui32Base == EPI0_BASE);
718  ASSERT(ui32MaxWait < 256);
719 
720  //
721  // Determine the CS and word access modes.
722  //
723  HWREG(ui32Base + EPI_O_HB16CFG2) =
724  ((ui32Config & EPI_HB16_CSBAUD) ? EPI_HB16CFG2_CSBAUD : 0) |
725  ((ui32Config & EPI_HB16_CSCFG_MASK) << 15);
726 
727  //
728  // Fill in the max wait field of the configuration word.
729  //
730  ui32Config &= ~EPI_HB16CFG_MAXWAIT_M;
731  ui32Config |= ui32MaxWait << EPI_HB16CFG_MAXWAIT_S;
732 
733  //
734  // Write the main HostBus16 configuration register.
735  //
736  HWREG(ui32Base + EPI_O_HB16CFG) = ui32Config;
737 }
738 
739 //*****************************************************************************
740 //
787 //
788 //*****************************************************************************
789 void
790 EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
791 {
792  uint32_t ui32Offset, ui32Reg;
793 
794  //
795  // Check the arguments.
796  //
797  ASSERT(ui32Base == EPI0_BASE);
798  ASSERT(ui32CS < 4);
799 
800  //
801  // Determine the register offset based on the ui32CS provided.
802  //
803  if(ui32CS < 2)
804  {
805  ui32Offset = EPI_O_HB8CFG + (ui32CS << 2);
806  }
807  else
808  {
809  ui32Offset = EPI_O_HB8CFG3 + ((ui32CS - 2) << 2);
810  }
811 
812  //
813  // Preserve the bits that will not be modified.
814  //
815  ui32Reg = HWREG(ui32Base + ui32Offset) & ~EPI_HB8_CS_MASK;
816 
817  //
818  // Write the target chip select HostBus8 configuration fields.
819  //
820  HWREG(ui32Base + ui32Offset) = (ui32Reg | ui32Config);
821 }
822 
823 //*****************************************************************************
824 //
874 //
875 //*****************************************************************************
876 void
877 EPIConfigHB16CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
878 {
879  uint32_t ui32Offset, ui32Reg;
880 
881  //
882  // Check the arguments.
883  //
884  ASSERT(ui32Base == EPI0_BASE);
885  ASSERT(ui32CS < 4);
886 
887  //
888  // Determine the register offset based on the ui32CS provided.
889  //
890  if(ui32CS < 2)
891  {
892  ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
893  }
894  else
895  {
896  ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
897  }
898 
899  //
900  // Preserve the bits that will not be modified.
901  //
902  ui32Reg = HWREG(ui32Base + ui32Offset) & ~EPI_HB16_CS_MASK;
903 
904  //
905  // Write the target chip select HostBus16 configuration fields.
906  //
907  HWREG(ui32Base + ui32Offset) = (ui32Reg | ui32Config);
908 }
909 
910 //*****************************************************************************
911 //
955 //
956 //*****************************************************************************
957 void
958 EPIConfigHB8TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
959 {
960  //
961  // Check the arguments.
962  //
963  ASSERT(ui32Base == EPI0_BASE);
964  ASSERT(ui32CS < 4);
965 
966  //
967  // Write the target chip select HostBus8 timing register.
968  //
969  HWREG(ui32Base + (EPI_O_HB8TIME + (ui32CS << 2))) = ui32Config;
970 }
971 
972 //*****************************************************************************
973 //
1030 //
1031 //*****************************************************************************
1032 void
1033 EPIConfigHB16TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
1034 {
1035  //
1036  // Check the arguments.
1037  //
1038  ASSERT(ui32Base == EPI0_BASE);
1039  ASSERT(ui32CS < 4);
1040 
1041  //
1042  // Write the target chip select HostBus16 timing register.
1043  //
1044  HWREG(ui32Base + (EPI_O_HB16TIME + (ui32CS << 2))) = ui32Config;
1045 }
1046 
1047 //*****************************************************************************
1048 //
1069 //
1070 //*****************************************************************************
1071 void
1072 EPIPSRAMConfigRegSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32CR)
1073 {
1074  uint32_t ui32Offset;
1075 
1076  //
1077  // Check the arguments.
1078  //
1079  ASSERT(ui32Base == EPI0_BASE);
1080  ASSERT(ui32CS < 4);
1081 
1082  //
1083  // Determine the register offset based on the ui32CS provided.
1084  //
1085  if(ui32CS < 2)
1086  {
1087  ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
1088  }
1089  else
1090  {
1091  ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
1092  }
1093 
1094  //
1095  // Setup for the PSRAM configuration register write. Only 21 bits are
1096  // valid on a write.
1097  //
1098  HWREG(ui32Base + EPI_O_HBPSRAM) = (ui32CR & 0x1fffff);
1099 
1100  //
1101  // Set the PSRAM configuration register write enable.
1102  //
1103  HWREG(ui32Base + ui32Offset) |= EPI_HB16CFG_WRCRE;
1104 }
1105 
1106 //*****************************************************************************
1107 //
1128 //
1129 //*****************************************************************************
1130 void
1131 EPIPSRAMConfigRegRead(uint32_t ui32Base, uint32_t ui32CS)
1132 {
1133  uint32_t ui32Offset;
1134 
1135  //
1136  // Check the arguments.
1137  //
1138  ASSERT(ui32Base == EPI0_BASE);
1139  ASSERT(ui32CS < 4);
1140 
1141  //
1142  // Determine the register offset based on the ui32CS provided.
1143  //
1144  if(ui32CS < 2)
1145  {
1146  ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
1147  }
1148  else
1149  {
1150  ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
1151  }
1152 
1153  //
1154  // Set the PSRAM configuration register read enable.
1155  //
1156  HWREG(ui32Base + ui32Offset) |= EPI_HB16CFG_RDCRE;
1157 }
1158 
1159 //*****************************************************************************
1160 //
1185 //
1186 //*****************************************************************************
1187 bool
1188 EPIPSRAMConfigRegGetNonBlocking(uint32_t ui32Base, uint32_t ui32CS,
1189  uint32_t *pui32CR)
1190 {
1191  uint32_t ui32Offset;
1192 
1193  //
1194  // Check the arguments.
1195  //
1196  ASSERT(ui32Base == EPI0_BASE);
1197  ASSERT(ui32CS < 4);
1198 
1199  //
1200  // Determine the register offset based on the ui32CS provided.
1201  //
1202  if(ui32CS < 2)
1203  {
1204  ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
1205  }
1206  else
1207  {
1208  ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
1209  }
1210 
1211  //
1212  // Verify PSRAM read enable is not asserted.
1213  //
1214  if(HWREG(ui32Base + ui32Offset) & EPI_HB16CFG_RDCRE)
1215  {
1216  return(false);
1217  }
1218 
1219  //
1220  // Copy the PSRAM configuration register value to the provided storage.
1221  // Only the lower 16 bits are valid on a read.
1222  //
1223  *pui32CR = HWREG(ui32Base + EPI_O_HBPSRAM) & 0xffff;
1224 
1225  //
1226  // Notify caller the provided storage holds the EPI PSRAM configuration
1227  // register contents.
1228  //
1229  return(true);
1230 }
1231 
1232 //*****************************************************************************
1233 //
1255 //
1256 //*****************************************************************************
1257 uint32_t
1258 EPIPSRAMConfigRegGet(uint32_t ui32Base, uint32_t ui32CS)
1259 {
1260  uint32_t ui32Offset;
1261 
1262  //
1263  // Check the arguments.
1264  //
1265  ASSERT(ui32Base == EPI0_BASE);
1266  ASSERT(ui32CS < 4);
1267 
1268  //
1269  // Determine the register offset based on the ui32CS provided.
1270  //
1271  if(ui32CS < 2)
1272  {
1273  ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
1274  }
1275  else
1276  {
1277  ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
1278  }
1279 
1280  //
1281  // Wait for PSRAM read enable to deassert if necessary.
1282  //
1283  while(HWREG(ui32Base + ui32Offset) & EPI_HB16CFG_RDCRE)
1284  {
1285  }
1286 
1287  //
1288  // Return the EPI PSRAM configuration register contents.
1289  // Only the lower 16 bits are valid on a read.
1290  //
1291  return(HWREG(ui32Base + EPI_O_HBPSRAM) & 0xffff);
1292 }
1293 
1294 //*****************************************************************************
1295 //
1332 //
1333 //*****************************************************************************
1334 void
1335 EPIConfigGPModeSet(uint32_t ui32Base, uint32_t ui32Config,
1336  uint32_t ui32FrameCount, uint32_t ui32MaxWait)
1337 {
1338  //
1339  // Check the arguments.
1340  //
1341  ASSERT(ui32Base == EPI0_BASE);
1342  ASSERT(ui32FrameCount < 16);
1343  ASSERT(ui32MaxWait < 256);
1344 
1345  //
1346  // Fill in the frame count field of the configuration word.
1347  //
1348  ui32Config &= ~EPI_GPCFG_FRMCNT_M;
1349  ui32Config |= ui32FrameCount << EPI_GPCFG_FRMCNT_S;
1350 
1351  //
1352  // Write the non-moded configuration register.
1353  //
1354  HWREG(ui32Base + EPI_O_GPCFG) = ui32Config;
1355 }
1356 
1357 //*****************************************************************************
1358 //
1412 //
1413 //*****************************************************************************
1414 void
1415 EPIAddressMapSet(uint32_t ui32Base, uint32_t ui32Map)
1416 {
1417  //
1418  // Check the arguments.
1419  //
1420  ASSERT(ui32Base == EPI0_BASE);
1421  ASSERT(ui32Map < 0x1000);
1422 
1423  //
1424  // Set the value of the address mapping register.
1425  //
1426  HWREG(ui32Base + EPI_O_ADDRMAP) = ui32Map;
1427 }
1428 
1429 //*****************************************************************************
1430 //
1457 //
1458 //*****************************************************************************
1459 void
1460 EPINonBlockingReadConfigure(uint32_t ui32Base, uint32_t ui32Channel,
1461  uint32_t ui32DataSize, uint32_t ui32Address)
1462 {
1463  uint32_t ui32Offset;
1464 
1465  //
1466  // Check the arguments.
1467  //
1468  ASSERT(ui32Base == EPI0_BASE);
1469  ASSERT(ui32Channel < 2);
1470  ASSERT(ui32DataSize < 4);
1471  ASSERT(ui32Address < 0x20000000);
1472 
1473  //
1474  // Compute the offset needed to select the correct channel regs.
1475  //
1476  ui32Offset = ui32Channel * (EPI_O_RSIZE1 - EPI_O_RSIZE0);
1477 
1478  //
1479  // Write the data size register for the channel.
1480  //
1481  HWREG(ui32Base + EPI_O_RSIZE0 + ui32Offset) = ui32DataSize;
1482 
1483  //
1484  // Write the starting address register for the channel.
1485  //
1486  HWREG(ui32Base + EPI_O_RADDR0 + ui32Offset) = ui32Address;
1487 }
1488 
1489 //*****************************************************************************
1490 //
1509 //
1510 //*****************************************************************************
1511 void
1512 EPINonBlockingReadStart(uint32_t ui32Base, uint32_t ui32Channel,
1513  uint32_t ui32Count)
1514 {
1515  uint32_t ui32Offset;
1516 
1517  //
1518  // Check the arguments.
1519  //
1520  ASSERT(ui32Base == EPI0_BASE);
1521  ASSERT(ui32Channel < 2);
1522  ASSERT(ui32Count < 4096);
1523 
1524  //
1525  // Compute the offset needed to select the correct channel regs.
1526  //
1527  ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
1528 
1529  //
1530  // Write to the read count register.
1531  //
1532  HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset) = ui32Count;
1533 }
1534 
1535 //*****************************************************************************
1536 //
1546 //
1547 //*****************************************************************************
1548 void
1549 EPINonBlockingReadStop(uint32_t ui32Base, uint32_t ui32Channel)
1550 {
1551  uint32_t ui32Offset;
1552 
1553  //
1554  // Check the arguments.
1555  //
1556  ASSERT(ui32Base == EPI0_BASE);
1557  ASSERT(ui32Channel < 2);
1558 
1559  //
1560  // Compute the offset needed to select the correct channel regs.
1561  //
1562  ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
1563 
1564  //
1565  // Write a 0 to the read count register, which cancels the transaction.
1566  //
1567  HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset) = 0;
1568 }
1569 
1570 //*****************************************************************************
1571 //
1581 //
1582 //*****************************************************************************
1583 uint32_t
1584 EPINonBlockingReadCount(uint32_t ui32Base, uint32_t ui32Channel)
1585 {
1586  uint32_t ui32Offset;
1587 
1588  //
1589  // Check the arguments.
1590  //
1591  ASSERT(ui32Base == EPI0_BASE);
1592  ASSERT(ui32Channel < 2);
1593 
1594  //
1595  // Compute the offset needed to select the correct channel regs.
1596  //
1597  ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
1598 
1599  //
1600  // Read the count remaining and return the value to the caller.
1601  //
1602  return(HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset));
1603 }
1604 
1605 //*****************************************************************************
1606 //
1617 //
1618 //*****************************************************************************
1619 uint32_t
1620 EPINonBlockingReadAvail(uint32_t ui32Base)
1621 {
1622  //
1623  // Check the arguments.
1624  //
1625  ASSERT(ui32Base == EPI0_BASE);
1626 
1627  //
1628  // Read the FIFO count and return it to the caller.
1629  //
1630  return(HWREG(ui32Base + EPI_O_RFIFOCNT));
1631 }
1632 
1633 //*****************************************************************************
1634 //
1649 //
1650 //*****************************************************************************
1651 uint32_t
1652 EPINonBlockingReadGet32(uint32_t ui32Base, uint32_t ui32Count,
1653  uint32_t *pui32Buf)
1654 {
1655  uint32_t ui32CountRead = 0;
1656 
1657  //
1658  // Check the arguments.
1659  //
1660  ASSERT(ui32Base == EPI0_BASE);
1661  ASSERT(ui32Count < 4096);
1662  ASSERT(pui32Buf);
1663 
1664  //
1665  // Read from the FIFO while there are any items to read and
1666  // the caller's specified count is not exceeded.
1667  //
1668  while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
1669  {
1670  //
1671  // Read from the FIFO and store in the caller supplied buffer.
1672  //
1673  *pui32Buf = HWREG(ui32Base + EPI_O_READFIFO0);
1674 
1675  //
1676  // Update the caller's buffer pointer and the count of items read.
1677  //
1678  pui32Buf++;
1679  ui32CountRead++;
1680  }
1681 
1682  //
1683  // Return the count of items read to the caller.
1684  //
1685  return(ui32CountRead);
1686 }
1687 
1688 //*****************************************************************************
1689 //
1704 //
1705 //*****************************************************************************
1706 uint32_t
1707 EPINonBlockingReadGet16(uint32_t ui32Base, uint32_t ui32Count,
1708  uint16_t *pui16Buf)
1709 {
1710  uint32_t ui32CountRead = 0;
1711 
1712  //
1713  // Check the arguments.
1714  //
1715  ASSERT(ui32Base == EPI0_BASE);
1716  ASSERT(ui32Count < 4096);
1717  ASSERT(pui16Buf);
1718 
1719  //
1720  // Read from the FIFO while there are any items to read, and
1721  // the caller's specified count is not exceeded.
1722  //
1723  while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
1724  {
1725  //
1726  // Read from the FIFO and store in the caller-supplied buffer.
1727  //
1728  *pui16Buf = (uint16_t)HWREG(ui32Base + EPI_O_READFIFO0);
1729 
1730  //
1731  // Update the caller's buffer pointer and the count of items read.
1732  //
1733  pui16Buf++;
1734  ui32CountRead++;
1735  }
1736 
1737  //
1738  // Return the count of items read to the caller.
1739  //
1740  return(ui32CountRead);
1741 }
1742 
1743 //*****************************************************************************
1744 //
1759 //
1760 //*****************************************************************************
1761 uint32_t
1762 EPINonBlockingReadGet8(uint32_t ui32Base, uint32_t ui32Count,
1763  uint8_t *pui8Buf)
1764 {
1765  uint32_t ui32CountRead = 0;
1766 
1767  //
1768  // Check the arguments.
1769  //
1770  ASSERT(ui32Base == EPI0_BASE);
1771  ASSERT(ui32Count < 4096);
1772  ASSERT(pui8Buf);
1773 
1774  //
1775  // Read from the FIFO while there are any items to read, and
1776  // the caller's specified count is not exceeded.
1777  //
1778  while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
1779  {
1780  //
1781  // Read from the FIFO and store in the caller supplied buffer.
1782  //
1783  *pui8Buf = (uint8_t)HWREG(ui32Base + EPI_O_READFIFO0);
1784 
1785  //
1786  // Update the caller's buffer pointer and the count of items read.
1787  //
1788  pui8Buf++;
1789  ui32CountRead++;
1790  }
1791 
1792  //
1793  // Return the count of items read to the caller.
1794  //
1795  return(ui32CountRead);
1796 }
1797 
1798 //*****************************************************************************
1799 //
1827 //
1828 //*****************************************************************************
1829 void
1830 EPIFIFOConfig(uint32_t ui32Base, uint32_t ui32Config)
1831 {
1832  //
1833  // Check the arguments.
1834  //
1835  ASSERT(ui32Base == EPI0_BASE);
1836  ASSERT(ui32Config == (ui32Config & 0x00030077));
1837 
1838  //
1839  // Load the configuration into the FIFO config reg.
1840  //
1841  HWREG(ui32Base + EPI_O_FIFOLVL) = ui32Config;
1842 }
1843 
1844 //*****************************************************************************
1845 //
1855 //
1856 //*****************************************************************************
1857 uint32_t
1858 EPIWriteFIFOCountGet(uint32_t ui32Base)
1859 {
1860  //
1861  // Check the arguments.
1862  //
1863  ASSERT(ui32Base == EPI0_BASE);
1864 
1865  //
1866  // Read the FIFO count and return it to the caller.
1867  //
1868  return(HWREG(ui32Base + EPI_O_WFIFOCNT));
1869 }
1870 
1871 //*****************************************************************************
1872 //
1889 //
1890 //*****************************************************************************
1891 void
1892 EPIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
1893 {
1894  //
1895  // Check the arguments.
1896  //
1897  ASSERT(ui32Base == EPI0_BASE);
1898  ASSERT(ui32IntFlags < 17);
1899 
1900  //
1901  // Write the interrupt flags mask to the mask register.
1902  //
1903  HWREG(ui32Base + EPI_O_IM) |= ui32IntFlags;
1904 }
1905 
1906 //*****************************************************************************
1907 //
1924 //
1925 //*****************************************************************************
1926 void
1927 EPIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
1928 {
1929  //
1930  // Check the arguments.
1931  //
1932  ASSERT(ui32Base == EPI0_BASE);
1933  ASSERT(ui32IntFlags < 17);
1934 
1935  //
1936  // Write the interrupt flags mask to the mask register.
1937  //
1938  HWREG(ui32Base + EPI_O_IM) &= ~ui32IntFlags;
1939 }
1940 
1941 //*****************************************************************************
1942 //
1960 //
1961 //*****************************************************************************
1962 uint32_t
1963 EPIIntStatus(uint32_t ui32Base, bool bMasked)
1964 {
1965  //
1966  // Check the arguments.
1967  //
1968  ASSERT(ui32Base == EPI0_BASE);
1969 
1970  //
1971  // Return either the interrupt status or the raw interrupt status as
1972  // requested.
1973  //
1974  if(bMasked)
1975  {
1976  return(HWREG(ui32Base + EPI_O_MIS));
1977  }
1978  else
1979  {
1980  return(HWREG(ui32Base + EPI_O_RIS));
1981  }
1982 }
1983 
1984 //*****************************************************************************
1985 //
2002 //
2003 //*****************************************************************************
2004 uint32_t
2005 EPIIntErrorStatus(uint32_t ui32Base)
2006 {
2007  //
2008  // Check the arguments.
2009  //
2010  ASSERT(ui32Base == EPI0_BASE);
2011 
2012  //
2013  // Read the error status and return to caller.
2014  //
2015  return(HWREG(ui32Base + EPI_O_EISC));
2016 }
2017 
2018 //*****************************************************************************
2019 //
2039 //
2040 //*****************************************************************************
2041 void
2042 EPIIntErrorClear(uint32_t ui32Base, uint32_t ui32ErrFlags)
2043 {
2044  //
2045  // Check the arguments.
2046  //
2047  ASSERT(ui32Base == EPI0_BASE);
2048  ASSERT(ui32ErrFlags < 0x20);
2049 
2050  //
2051  // Write the error flags to the register to clear the pending errors.
2052  //
2053  HWREG(ui32Base + EPI_O_EISC) = ui32ErrFlags;
2054 }
2055 
2056 //*****************************************************************************
2057 //
2067 //
2068 //*****************************************************************************
2069 static uint32_t
2070 _EPIIntNumberGet(uint32_t ui32Base)
2071 {
2072  uint32_t ui32Int;
2073 
2074  //
2075  // Check the arguments.
2076  //
2077  ASSERT(ui32Base == EPI0_BASE);
2078 
2079  //
2080  // By default, assume EPI is not supported.
2081  //
2082  ui32Int = 0;
2083 
2084  if(CLASS_IS_TM4C129)
2085  {
2086  ui32Int = INT_EPI0_TM4C129;
2087  }
2088 
2089  return(ui32Int);
2090 }
2091 
2092 //*****************************************************************************
2093 //
2108 //
2109 //*****************************************************************************
2110 void
2111 EPIIntRegister(uint32_t ui32Base, void (*pfnHandler)(void))
2112 {
2113  uint32_t ui32Int;
2114 
2115  //
2116  // Check the arguments.
2117  //
2118  ASSERT(ui32Base == EPI0_BASE);
2119  ASSERT(pfnHandler);
2120 
2121  //
2122  // Get the interrupt number for the EPI interface.
2123  //
2124  ui32Int = _EPIIntNumberGet(ui32Base);
2125 
2126  ASSERT(ui32Int != 0);
2127 
2128  //
2129  // Register the interrupt handler.
2130  //
2131  IntRegister(ui32Int, pfnHandler);
2132 
2133  //
2134  // Enable the EPI interface interrupt.
2135  //
2136  IntEnable(ui32Int);
2137 }
2138 
2139 //*****************************************************************************
2140 //
2152 //
2153 //*****************************************************************************
2154 void
2155 EPIIntUnregister(uint32_t ui32Base)
2156 {
2157  uint32_t ui32Int;
2158 
2159  //
2160  // Check the arguments.
2161  //
2162  ASSERT(ui32Base == EPI0_BASE);
2163 
2164  //
2165  // Get the interrupt number for the EPI interface.
2166  //
2167  ui32Int = _EPIIntNumberGet(ui32Base);
2168 
2169  ASSERT(ui32Int != 0);
2170 
2171  //
2172  // Disable the EPI interface interrupt.
2173  //
2174  IntDisable(ui32Int);
2175 
2176  //
2177  // Unregister the interrupt handler.
2178  //
2179  IntUnregister(ui32Int);
2180 }
2181 
2182 //*****************************************************************************
2183 //
2184 // Close the Doxygen group.
2186 //
2187 //*****************************************************************************
#define EPI_HB8_CSBAUD
Definition: epi.h:137
uint32_t EPINonBlockingReadGet8(uint32_t ui32Base, uint32_t ui32Count, uint8_t *pui8Buf)
Definition: epi.c:1762
void EPINonBlockingReadStart(uint32_t ui32Base, uint32_t ui32Channel, uint32_t ui32Count)
Definition: epi.c:1512
#define EPI_O_BAUD
Definition: hw_epi.h:50
void EPIDMATxCount(uint32_t ui32Base, uint32_t ui32Count)
Definition: epi.c:391
void EPIConfigHB8Set(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32MaxWait)
Definition: epi.c:569
void EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value)
#define HWREG(x)
Definition: hw_types.h:48
#define EPI_O_HB8TIME
Definition: hw_epi.h:88
#define EPI_O_MIS
Definition: hw_epi.h:81
#define EPI_O_RPSTD0
Definition: hw_epi.h:62
#define EPI_O_RSIZE0
Definition: hw_epi.h:60
#define EPI_O_GPCFG
Definition: hw_epi.h:53
#define EPI_GPCFG_FRMCNT_S
Definition: hw_epi.h:193
#define EPI_HB8_CSCFG_MASK
Definition: epi.h:145
#define EPI_O_FIFOLVL
Definition: hw_epi.h:76
void EPIModeSet(uint32_t ui32Base, uint32_t ui32Mode)
Definition: epi.c:252
#define EPI_HB8_CS_MASK
Definition: epi.c:63
void EPIConfigHB8TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
Definition: epi.c:958
#define ASSERT(expr)
Definition: debug.h:67
#define EPI_SDRAMCFG_RFSH_S
Definition: hw_epi.h:211
#define EPI_MODE_HB16
Definition: epi.h:62
void EPINonBlockingReadConfigure(uint32_t ui32Base, uint32_t ui32Channel, uint32_t ui32DataSize, uint32_t ui32Address)
Definition: epi.c:1460
void EPIConfigHB16TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
Definition: epi.c:1033
uint32_t EPINonBlockingReadGet16(uint32_t ui32Base, uint32_t ui32Count, uint16_t *pui16Buf)
Definition: epi.c:1707
void EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value)
#define EPI_SDRAMCFG_RFSH_M
Definition: hw_epi.h:204
uint32_t EPINonBlockingReadCount(uint32_t ui32Base, uint32_t ui32Channel)
Definition: epi.c:1584
void EPIConfigHB16Set(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32MaxWait)
Definition: epi.c:712
#define EPI_MODE_GENERAL
Definition: epi.h:59
#define EPI_HB8CFG2_CSBAUD
Definition: hw_epi.h:253
void EPIPSRAMConfigRegSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32CR)
Definition: epi.c:1072
#define EPI_O_RSIZE1
Definition: hw_epi.h:63
#define EPI_HB16CFG_RDCRE
Definition: hw_epi.h:148
uint32_t EPIWorkaroundWordRead(uint32_t *pui32Addr)
#define EPI_O_HB16CFG3
Definition: hw_epi.h:85
void EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value)
#define EPI_O_RIS
Definition: hw_epi.h:80
#define EPI_HB16CFG_MAXWAIT_M
Definition: hw_epi.h:151
#define EPI_O_HB8CFG2
Definition: hw_epi.h:57
#define EPI_O_HB8CFG
Definition: hw_epi.h:56
#define EPI_O_HB16CFG
Definition: hw_epi.h:52
uint32_t EPIPSRAMConfigRegGet(uint32_t ui32Base, uint32_t ui32CS)
Definition: epi.c:1258
#define EPI_HB16CFG_MAXWAIT_S
Definition: hw_epi.h:168
void EPIIntErrorClear(uint32_t ui32Base, uint32_t ui32ErrFlags)
Definition: epi.c:2042
uint32_t EPINonBlockingReadAvail(uint32_t ui32Base)
Definition: epi.c:1620
#define EPI_O_HB16CFG2
Definition: hw_epi.h:58
#define EPI0_BASE
Definition: hw_memmap.h:129
void EPINonBlockingReadStop(uint32_t ui32Base, uint32_t ui32Channel)
Definition: epi.c:1549
#define EPI_O_RADDR0
Definition: hw_epi.h:61
void EPIConfigGPModeSet(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32FrameCount, uint32_t ui32MaxWait)
Definition: epi.c:1335
#define EPI_O_IM
Definition: hw_epi.h:79
#define EPI_O_EISC
Definition: hw_epi.h:82
#define EPI_HB8CFG_MAXWAIT_M
Definition: hw_epi.h:228
#define EPI_O_ADDRMAP
Definition: hw_epi.h:59
void EPIFIFOConfig(uint32_t ui32Base, uint32_t ui32Config)
Definition: epi.c:1830
uint32_t EPIIntErrorStatus(uint32_t ui32Base)
Definition: epi.c:2005
#define EPI_MODE_DISABLE
Definition: epi.h:63
void EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Divider)
Definition: epi.c:339
#define EPI_MODE_HB8
Definition: epi.h:61
#define INT_EPI0_TM4C129
Definition: hw_ints.h:226
#define EPI_HB16CFG2_CSBAUD
Definition: hw_epi.h:285
#define EPI_GPCFG_FRMCNT_M
Definition: hw_epi.h:178
#define EPI_O_CFG
Definition: hw_epi.h:49
bool EPIPSRAMConfigRegGetNonBlocking(uint32_t ui32Base, uint32_t ui32CS, uint32_t *pui32CR)
Definition: epi.c:1188
void EPIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: epi.c:1892
#define EPI_HB16CFG_WRCRE
Definition: hw_epi.h:146
void EPIConfigSDRAMSet(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32Refresh)
Definition: epi.c:444
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
#define EPI_O_BAUD2
Definition: hw_epi.h:51
#define EPI_O_HBPSRAM
Definition: hw_epi.h:96
void EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
Definition: epi.c:790
#define EPI_MODE_SDRAM
Definition: epi.h:60
uint32_t EPINonBlockingReadGet32(uint32_t ui32Base, uint32_t ui32Count, uint32_t *pui32Buf)
Definition: epi.c:1652
uint16_t EPIWorkaroundHWordRead(uint16_t *pui16Addr)
#define EPI_O_HB16TIME
Definition: hw_epi.h:89
#define EPI_O_READFIFO0
Definition: hw_epi.h:68
#define EPI_HB16_CSBAUD
Definition: epi.h:190
void EPIAddressMapSet(uint32_t ui32Base, uint32_t ui32Map)
Definition: epi.c:1415
#define EPI_HB16_CS_MASK
Definition: epi.c:67
void EPIIntUnregister(uint32_t ui32Base)
Definition: epi.c:2155
#define EPI_HB16_CSCFG_MASK
Definition: epi.h:191
void EPIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: epi.c:1927
#define EPI_O_WFIFOCNT
Definition: hw_epi.h:77
#define EPI_O_RFIFOCNT
Definition: hw_epi.h:67
uint8_t EPIWorkaroundByteRead(uint8_t *pui8Addr)
void EPIDividerSet(uint32_t ui32Base, uint32_t ui32Divider)
Definition: epi.c:298
#define CLASS_IS_TM4C129
Definition: hw_types.h:99
#define EPI_O_SDRAMCFG
Definition: hw_epi.h:55
#define EPI_O_DMATXCNT
Definition: hw_epi.h:78
uint32_t EPIWriteFIFOCountGet(uint32_t ui32Base)
Definition: epi.c:1858
void EPIIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: epi.c:2111
uint32_t EPIIntStatus(uint32_t ui32Base, bool bMasked)
Definition: epi.c:1963
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684
void EPIConfigHB16CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
Definition: epi.c:877
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
#define EPI_O_RPSTD1
Definition: hw_epi.h:65
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610
static uint32_t _EPIIntNumberGet(uint32_t ui32Base)
Definition: epi.c:2070
#define EPI_HB8CFG_MAXWAIT_S
Definition: hw_epi.h:244
void EPIPSRAMConfigRegRead(uint32_t ui32Base, uint32_t ui32CS)
Definition: epi.c:1131
#define EPI_O_HB8CFG3
Definition: hw_epi.h:84