Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. //PROGRAMUL 1
  2.  
  3. #include <sys/platform.h>
  4. #include "BDPN.h"
  5. #include "adi_initialize.h"
  6. #include <cdefBF537.h>
  7.  
  8. char __argv_string[] = "";
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. adi_initComponents();
  13.  
  14. *pPORTFIO_DIR = 0x0FC0;
  15. *pPORTFIO_INEN = 0x0004;
  16. *pPORTFIO = 0x0000;
  17.  
  18. volatile unsigned int i;
  19.  
  20. while(1) {
  21. *pPORTFIO |= (1<<6);
  22. for(int i = 0; i<=999999 ;i++);
  23. *pPORTFIO &= ~(1<<6);
  24. for(int i = 0; i<=999999 ;i++);
  25. }
  26.  
  27. return 0;
  28. }
  29.  
  30. //PROGRAMUL 2
  31.  
  32. #include <sys/platform.h>
  33. #include "BDPN.h"
  34. #include "adi_initialize.h"
  35. #include <cdefBF537.h>
  36.  
  37. char __argv_string[] = "";
  38.  
  39. int main(int argc, char *argv[])
  40. {
  41. adi_initComponents();
  42.  
  43. *pPORTFIO_DIR = 0x0FC0;
  44. *pPORTFIO_INEN = 0x0004;
  45. *pPORTFIO = 0x0000;
  46.  
  47. volatile unsigned int i;
  48. volatile unsigned int k=0;
  49.  
  50. while(1) {
  51. if(*pPORTFIO & (1<<2)) {
  52. while(*pPORTFIO & (1<<2));
  53. if(k%2==0){
  54. *pPORTFIO = (1<<6);
  55. k++;
  56. }
  57. else
  58. {*pPORTFIO = (0<<6);
  59. k++;
  60. }
  61. }
  62. }
  63. return 0;
  64. }
  65.  
  66. //PROGRAMUL 3
  67.  
  68. #include <sys/platform.h>
  69. #include "BDPN.h"
  70. #include "adi_initialize.h"
  71. #include <cdefBF537.h>
  72.  
  73. char __argv_string[] = "";
  74.  
  75. void LIGHT_LEDS(){
  76. int led_pos = 6; //ultimul led
  77. *pPORTFIO ^= (1 << led_pos); //ultimul led aprins
  78. while(1){
  79.  
  80. if(*pPORTFIO&0x0008){ //al doilea buton -> o ia in stinga
  81. while(*pPORTFIO&0x0008);
  82. if(led_pos == 6){ //daca e deja in capat si apasam stanga o sa aprinda ledul din celalat capat
  83. *pPORTFIO ^= (1 << 6);
  84. led_pos = 11;
  85. *pPORTFIO ^= (1 << 11);
  86. } else { //daca nu, decrementeaza pozitia
  87. *pPORTFIO ^= (1 << led_pos);
  88. *pPORTFIO ^= (1 << led_pos-1);
  89. led_pos--;
  90. }
  91. }
  92.  
  93. if(*pPORTFIO&0x0004){ //primul buton -> o ia in dreapta
  94. while(*pPORTFIO&0x0004);
  95. if(led_pos == 11){ //daca e deja in capat si apasam dreapta o sa aprinda ledul din celalat capat
  96. *pPORTFIO ^= (1 << 11);
  97. led_pos = 6;
  98. *pPORTFIO ^= (1 << 6);
  99. } else { //daca nu, incrementeaza pozitia
  100. *pPORTFIO ^= (1 << led_pos);
  101. *pPORTFIO ^= (1 << led_pos+1);
  102. led_pos++;
  103. }
  104. }
  105. }
  106. }
  107.  
  108. int main(int argc, char *argv[])
  109. {
  110. adi_initComponents();
  111.  
  112. *pPORTFIO_DIR = 0x0FC0;
  113. *pPORTFIO_INEN = 0x003F;
  114.  
  115. LIGHT_LEDS();
  116.  
  117. return 0;
  118. }
  119.  
  120.  
  121.  
  122. //PROGRAMUL 3
  123.  
  124. #include <sys/platform.h>
  125. #include <sys/exception.h>
  126. #include <cdefbf537.h>
  127. #include "adi_initialize.h"
  128. #include "PNEB.h"
  129.  
  130. char __argv_string[] = "";
  131.  
  132. void initreg() {
  133. *pPORTFIO_DIR=0x0FC0;
  134. *pPORTFIO_INEN = 0x003F;
  135.  
  136. *pTIMER7_PERIOD = 25000000;
  137. *pTIMER7_CONFIG = 0x001D;
  138. *pTIMER_ENABLE = 0x0080;
  139. }
  140.  
  141. void blinkerino() {
  142.  
  143. volatile unsigned int k;
  144.  
  145. while(1) {
  146. if(*pTIMER_STATUS&0x00080000) {
  147. if(k%2==0) {
  148. *pPORTFIO= (1<<6);
  149. k++;
  150. }
  151. else
  152. if(k%2!=0) {
  153. *pPORTFIO= (0<<6);
  154. k++;
  155. }
  156. }
  157. *pTIMER_STATUS=0x00080000;
  158. }
  159. }
  160.  
  161. int main(int argc, char *argv[])
  162. {
  163. adi_initComponents();
  164.  
  165. initreg();
  166.  
  167. blinkerino();
  168.  
  169. return 0;
  170. }
  171.  
  172. //PROGRAMUL 4
  173.  
  174. #include <sys/platform.h>
  175. #include <sys/exception.h>
  176. #include <cdefbf537.h>
  177. #include "adi_initialize.h"
  178. #include "PNEB.h"
  179.  
  180. char __argv_string[] = "";
  181.  
  182. volatile unsigned int k=0;
  183.  
  184. EX_INTERRUPT_HANDLER(ISR_Timer7) {
  185. *pTIMER_STATUS = 0x00080000;
  186. if(k%2==0) {
  187. *pPORTFIO = (1<<6);
  188. k++;
  189. }
  190. else
  191. if(k%2!=0) {
  192. *pPORTFIO = (0<<6);
  193. k++;
  194. }
  195. }
  196.  
  197. void initInterrupts(void) {
  198. *pSIC_IAR3 = 0xFFFFF5FF;
  199. *pSIC_IMASK = 0x04000000;
  200. register_handler(ik_ivg12, ISR_Timer7);
  201. }
  202.  
  203. void initreg() {
  204. *pPORTFIO_DIR = 0x0FC0;
  205. *pPORTFIO_INEN = 0x003F;
  206.  
  207. *pTIMER7_PERIOD = 25000000;
  208. *pTIMER7_CONFIG = 0x001D;
  209. *pTIMER_ENABLE = 0x0080;
  210. }
  211.  
  212. void blinkerino() {
  213. while(1) {}
  214. }
  215.  
  216. int main(int argc, char *argv[])
  217. {
  218. adi_initComponents();
  219.  
  220. initInterrupts();
  221.  
  222. initreg();
  223.  
  224. blinkerino();
  225.  
  226. /* DE PE TABLA ?
  227. volatile unsigned int n, f;
  228. float t;
  229.  
  230. f = 50000;
  231. t=0.5;
  232. n=(int) t*f;
  233. */
  234.  
  235. return 0;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement