/programy/Atmel32_C/compass/compass.cpp |
---|
0,0 → 1,176 |
/*****************************************************************************/ |
/* |
* compass.cpp - communication with digital compass module |
* |
* Copyright (C) 2007 Jakub Kakona |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* |
* |
* Revision history |
* 10.08.2007 1.0 Initial release |
*/ |
/*****************************************************************************/ |
#include <iostream> |
#include <getopt.h> |
#include <errno.h> |
#include <string.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include "linux/i2c-dev.h" |
#include <sys/ioctl.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
using namespace std; |
static char* version = "CompassControlloler, version 0.1"; |
static char* help = "Usage: BoardController [OPTION]\n -I\t\tshow ID\n -M\t\tshow model\n -R\t\tshow revision\n -S\t\tshow serial no.\n -T\t\tshow temperature\n\n"; |
#define I2C_SLAVE 0x0703 /* Change slave address */ |
#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ |
#define BC_Addr 0xC0 |
void DoExit(int ex) |
{ |
exit(ex); |
} |
unsigned char xfunc[5] = {0x99, 0x9A, 0x9B, 0x9E, 0x8D}; |
unsigned char xlen[5] = {8, 6, 1, 15, 2}; |
int main(int argc, char *argv[], char *envp[]) |
{ |
char *progname; |
int c, func = 0, Len; |
int i2cbus = 0; |
char filename[20], Buf[64]; |
int file; |
progname = strrchr(argv[0], '/'); |
progname = progname ? progname + 1 : argv[0]; |
while ((c = getopt (argc, argv, "IiMmRrSsTth")) != -1) |
switch (c) |
{ |
case 'I': |
case 'i': |
func = 0; |
break; |
case 'M': |
case 'm': |
func = 1; |
break; |
case 'R': |
case 'r': |
func = 2; |
break; |
case 'S': |
case 's': |
func = 3; |
break; |
case 'T': |
case 't': |
func = 4; |
break; |
case 'h': |
printf ("%s\n%s", version, help); |
return 1; |
case '?': |
printf ("Unknown option `-%c', try %s -h.\n", optopt,progname); |
return 1; |
} |
sprintf(filename, "/dev/i2c-%d", i2cbus); |
file = open(filename, O_RDWR); |
if (file < 0) |
{ |
cerr << "Could not open /dev/i2c-0." << endl; |
return -1; |
} |
if (ioctl(file, I2C_SLAVE, BC_Addr) == -1) |
{ |
fprintf(stderr, "Failed to set address to 0x%02x.\n", BC_Addr); |
DoExit(-2); |
} |
int Loops = 0; |
do |
{ |
Buf[0] = xfunc[func]; |
if ( write(file, Buf, 1) != 1) |
{ |
fprintf(stderr, "Failed to write byte to address to 0x%02x, errno %i.\n", BC_Addr, errno); |
DoExit(-3); |
} |
if (read(file, Buf, 1) != 1) |
{ |
fprintf(stderr, "Failed to read response length, errno %i.\n", errno); |
DoExit(-4); |
} |
Len = Buf[0]; |
if (read(file, Buf, Len) != Len) |
{ |
fprintf(stderr, "Failed to read response, errno %i.\n", errno); |
DoExit(-5); |
} |
Loops++; |
} while (Len != xlen[func]); |
if (Loops > 1) |
fprintf(stderr, "After %i attempts got: \n", Loops); |
switch (func) |
{ |
case 0: |
Buf[Len] = 0x00; |
fprintf(stdout, "Board ID is %s.\n", Buf); |
break; |
case 1: |
Buf[Len] = 0x00; |
fprintf(stdout, "Model of the board is %s.\n", Buf); |
break; |
case 2: |
fprintf(stdout, "Revision of the board is 0x%02X.\n", Buf[0]); |
break; |
case 3: |
Buf[Len] = 0x00; |
fprintf(stdout, "Serial number of the board is %s.\n", Buf); |
break; |
case 4: |
fprintf(stdout, "Temperature is %i or %i.\n", (Buf[0] << 8) + Buf[1], (Buf[1] << 8) + Buf[0]); |
break; |
} |
close(file); |
return 0; |
} |
/programy/Atmel32_C/hello/hello.elf |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programy/Atmel32_C/linux-kernel/config |
---|
1,7 → 1,7 |
# |
# Automatically generated make config: don't edit |
# Linux kernel version: 2.6.22.atmel.2 |
# Mon Jul 23 21:56:02 2007 |
# Wed Aug 8 23:52:11 2007 |
# |
CONFIG_AVR32=y |
CONFIG_GENERIC_GPIO=y |
162,6 → 162,8 |
# CPU Frequency scaling |
# |
# CONFIG_CPU_FREQ is not set |
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set |
# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set |
# |
# Bus options |
199,6 → 201,8 |
CONFIG_INET=y |
CONFIG_IP_MULTICAST=y |
# CONFIG_IP_ADVANCED_ROUTER is not set |
# CONFIG_ASK_IP_FIB_HASH is not set |
# CONFIG_IP_FIB_TRIE is not set |
CONFIG_IP_FIB_HASH=y |
CONFIG_IP_PNP=y |
CONFIG_IP_PNP_DHCP=y |
230,6 → 234,9 |
# CONFIG_NETFILTER is not set |
# CONFIG_IP_DCCP is not set |
# CONFIG_IP_SCTP is not set |
# CONFIG_SCTP_HMAC_NONE is not set |
# CONFIG_SCTP_HMAC_SHA1 is not set |
# CONFIG_SCTP_HMAC_MD5 is not set |
# CONFIG_TIPC is not set |
# CONFIG_ATM is not set |
# CONFIG_BRIDGE is not set |
/programy/C/SID/sidd |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programy/C/SID/sidd.c |
---|
28,7 → 28,7 |
// Tuneable Settings // |
/////////////////////////////////////////////////////////////////////////////// |
#define VERSION "0.93" |
#define VERSION "0.94" |
// |
// Number of soundcard bytes to read at a time. |
79,9 → 79,20 |
// Mixer gain settings requested by config file. |
int req_lgain = -1; // Line gain |
int req_mgain = -1; // Microphone gain |
int req_igain = -1; // Input gain |
int req_rgain = -1; // Record level |
// Actual mixer values, read by open_mixer() |
int mixer_recmask; // Recording device mask |
int mixer_stereo; // Stereo device mask |
int mixer_line; // Line input gain setting |
int mixer_microphone; // Microphone input gain |
int mixer_igain; // Overall input gain setting |
int mixer_reclev; // Recording level setting |
int mixer_recsrc; // Mask indicating which inputs are set to record |
// |
// Various filenames, contents set by config file. |
// |
662,8 → 673,18 |
int right = atoi( fields[3]); |
int gain = (right << 8) | left; |
if( !strcasecmp( fields[1], "line")) req_lgain = gain; |
if( !strcasecmp( fields[1], "line")) |
{ |
req_lgain = gain; |
mixer_recsrc = SOUND_MASK_LINE; |
} |
else |
if( !strcasecmp( fields[1], "mic")) |
{ |
req_mgain = gain; |
mixer_recsrc = SOUND_MASK_MIC; |
} |
else |
if( !strcasecmp( fields[1], "overall")) req_igain = gain; |
else |
if( !strcasecmp( fields[1], "record")) req_rgain = gain; |
695,14 → 716,6 |
// Mixer Stuff // |
/////////////////////////////////////////////////////////////////////////////// |
// Actual mixer values, read by open_mixer() |
int mixer_recmask; // Recording device mask |
int mixer_stereo; // Stereo device mask |
int mixer_line; // Line input gain setting |
int mixer_igain; // Overall input gain setting |
int mixer_reclev; // Recording level setting |
int mixer_recsrc; // Mask indicating which inputs are set to record |
void open_mixer( void) |
{ |
if( (fdm = open( mixer, O_RDWR)) < 0) |
782,6 → 795,19 |
mixer_line & 0xff, (mixer_line >> 8) & 0xff); |
} |
if( req_mgain >= 0) |
{ |
report( 1, "requesting microphone input gains left=%d right=%d", |
req_mgain & 0xff, (req_mgain >> 8) & 0xff); |
if( ioctl( fdm, SOUND_MIXER_WRITE_MIC, &req_mgain) < 0 || |
ioctl( fdm, SOUND_MIXER_READ_MIC, &mixer_microphone) < 0) |
bailout( "error setting mixer microphone gain"); |
report( 1, "Microphone input gains set to: left=%d right=%d", |
mixer_microphone & 0xff, (mixer_microphone >> 8) & 0xff); |
} |
if( req_igain >= 0 && |
(mixer_recmask & SOUND_MASK_IGAIN)) |
{ |
810,9 → 836,24 |
mixer_reclev & 0xff, (mixer_reclev >> 8) & 0xff); |
} |
mixer_recsrc = SOUND_MASK_LINE; |
if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0) |
bailout( "cannot set mixer recsrc to line"); |
//mixer_recsrc= SOUND_MASK_LINE; |
mixer_recsrc= SOUND_MASK_MIC; |
switch (mixer_recsrc) |
{ |
case SOUND_MASK_MIC: |
if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0) |
bailout( "cannot set mixer recsrc to microphone"); |
else report(1, "Input device set to microphone"); |
break; |
case SOUND_MASK_LINE: |
if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0) |
bailout( "cannot set mixer recsrc to line"); |
else report(1, "Input device set to line"); |
break; |
} |
} |
/////////////////////////////////////////////////////////////////////////////// |
/programy/C/SID/sidd.conf |
---|
26,13 → 26,15 |
; Line input gains, left and right. If using mono, set them both the same. |
; Range is 0 to 100. The logfile will report the actual values set, which |
; may differ a little. |
gain line 77 100 |
;gain line 77 100 |
gain mic 100 100 |
; Overall input gains, comments as above. |
gain overall 86 100 |
;gain overall 86 100 |
; Overall record level, comments as above. |
;; gain record 100 100 |
;gain record 100 100 |
; Specify a directory to contain daily data files. Use '.' for the |
; current directory. Output files will be datadir/yymmdd.dat when running |
66,10 → 68,10 |
; sidd. |
; |
; ident from to |
band 18k3HWU 18200 18400 ; Le Blanc, France, 46:37N 001:05E 162.8 deg 508.6 miles |
band 19k6GBZ 19480 19680 ; Anthorn, UK 54:54n 003:18W 329.6 deg 96.4 miles |
band 22k1GBZ 22050 22150 ; Skelton, UK, 54:42:24N 2:53:06W 335.0 deg 76.7 miles |
band 20k3ICV 20190 20340 ; Tavolara, Italy, 40:55N 009:45E 143.4 deg 1038.8 miles |
band 18k3HWU 18200 18400 ; Le Blanc, France |
band 19k6GBZ 19480 19680 ; Anthorn, UK |
band 22k1GBZ 22050 22150 ; Skelton, UK |
band 20k3ICV 20190 20340 ; Tavolara, Italy |
band B1 20800 21000 ; Background channel |
band B2 22650 22850 ; Background channel |