Subversion Repositories Projects

Rev

Rev 471 | Rev 728 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 471 Rev 507
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
3
 *   admiralcascade@gmail.com                                               *
3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
 *                                                                          *
5
 *                                                                          *
6
 *   This program is free software; you can redistribute it and/or modify   *
6
 *   This program is free software; you can redistribute it and/or modify   *
7
 *   it under the terms of the GNU General Public License as published by   *
7
 *   it under the terms of the GNU General Public License as published by   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
19
 ****************************************************************************/
-
 
20
 
-
 
21
/*
-
 
22
 * structs 'n union for easy SPI transfer
-
 
23
 */
-
 
24
typedef struct {
-
 
25
        int16_t ampere;
-
 
26
        int32_t mah;
-
 
27
        int16_t volt;
-
 
28
} __attribute__((packed)) SPI_strom_data_t;
-
 
29
 
-
 
30
typedef struct {
-
 
31
        uint8_t c[10];
-
 
32
        uint8_t chk;
-
 
33
} __attribute__((packed)) SPI_char_buffer_t;
-
 
34
 
-
 
35
union SPI_buffer_t {
-
 
36
  SPI_strom_data_t data;
-
 
37
  SPI_char_buffer_t buffer;
-
 
38
};
-
 
39
 
-
 
40
volatile union SPI_buffer_t SPI_buffer;
20
 
41
 
21
/**
42
/**
22
 * SPI interrupt handler
43
 * SPI interrupt handler
23
 */
44
 */
24
ISR(SPI_STC_vect);
45
ISR(SPI_STC_vect);
25
 
46
 
26
/**
47
/**
27
 * init the SPI as master
48
 * init the SPI as master
28
 */
49
 */
29
void SpiMasterInit(void);
50
void SpiMasterInit(void);
30
 
51
 
31
/**
52
/**
32
 * check if SPI transfer is still busy
53
 * check if SPI transfer is still busy
33
 */
54
 */
34
int TransferIsBusy(void);
55
int TransferIsBusy(void);
35
 
56
 
36
/**
57
/**
37
 * start a new transfer of <data> with length <len>
58
 * start a new transfer with length <len>
-
 
59
 */
-
 
60
void StartTransfer(uint16_t);
-
 
61
 
-
 
62
/**
-
 
63
 * send next command through spi
38
 */
64
 */
39
void StartTransfer(unsigned char *, uint16_t);
65
void spi_send_next();
40
 
66