##// END OF EJS Templates
First beam is loaded by default after sending the beam file to the control modules.
First beam is loaded by default after sending the beam file to the control modules.

File last commit:

r116:117
r231:232
Show More
at91sysclock.c
55 lines | 1.2 KiB | text/x-c | CLexer
/*
* This programmer uses AT91' System clock
*
* 2010 by Ricardo V. Rojas Quispe
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include "./Librerias/at91sysclock.h"
//Mapeando los registro en memoria:
AT91S_PMC *clock_map(unsigned int clockbase){
int fd;
void *base;
AT91S_PMC *clock;
off_t addr = clockbase;
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
fprintf(stderr, "Cannot open /dev/mem.\n");
exit(EXIT_FAILURE);
}
//fprintf(stderr, "/dev/mem opened.\n");
base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK);
if (base == (void *) -1) {
fprintf(stderr, "Cannot open /dev/mem.\n");
exit(EXIT_FAILURE);
}
//fprintf(stderr, "Memory mapped at address %p.\n", base);
clock = base + (addr & MAP_MASK);
return clock;
}
//Habilitamos el clock de ADC
void enable_clock_adc(AT91S_PMC * clock){
clock->PMC_PCER=0x20;
}
//Leemos el registro de estado de clock para perifericos
unsigned int status_clock_adc(AT91S_PMC * clock){
return (clock->PMC_PCSR);
}