Advertisement
Guest User

Untitled

a guest
Nov 21st, 2010
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <csl_gpio.h>
  4. #include <csl_general.h>
  5.  
  6. CSL_GpioObj     GpioObj;
  7. CSL_GpioObj     *hGpio;
  8.  
  9. void main(void){
  10.     CSL_Status status;
  11.     CSL_GpioPinConfig config;
  12.     int i=0;   
  13.     short toggle=0x00;
  14.     printf("%d",sizeof(int));
  15. /*  // Reset interrupts and set vector table
  16.     IRQ_globalDisable();
  17.     IRQ_clearAll();
  18.     IRQ_disableAll();
  19.    
  20.     IRQ_setVecs((Uint32)(&VECSTART));
  21. */ 
  22.     // Open GPIO module
  23.     hGpio = GPIO_open(&GpioObj,&status);
  24.     if((NULL == hGpio) || (CSL_SOK != status))
  25.     {
  26.         printf("GPIO open failed\n");
  27.     }
  28.     else
  29.     {
  30.         printf("GPIO_open Successful\n");
  31.     }
  32.        
  33.     // Reset GPIO module
  34.     GPIO_reset(hGpio);
  35.    
  36.     // GPIO_config API to make PIN14 as output
  37.     config.pinNum = CSL_GPIO_PIN14;
  38.     config.direction = CSL_GPIO_DIR_OUTPUT;
  39.     config.trigger = CSL_GPIO_TRIG_CLEAR_EDGE;
  40.    
  41.     status = GPIO_configBit(hGpio,&config);
  42.     if(CSL_SOK != status)
  43.     {
  44.         printf("test failed - GPIO_configBit\n");
  45.     }
  46.     else
  47.     {
  48.         printf("GPIO PIN14 and 15 are configured as output pins\n");
  49.     }
  50.    
  51.    
  52.        
  53.     while(1){
  54.         status = GPIO_write(hGpio,CSL_GPIO_PIN14,toggle);
  55.         for(i=0;i<=50000000; i++){
  56.             asm(" nop");
  57.         }
  58.         toggle^=0x01;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement