Browse Source

Renamed spi_ methods to match other libs

Thomas Buck 8 years ago
parent
commit
10cbeb7bce
3 changed files with 15 additions and 15 deletions
  1. 3
    3
      include/spi.h
  2. 9
    9
      src/cc2500.c
  3. 3
    3
      src/spi.c

+ 3
- 3
include/spi.h View File

25
 
25
 
26
 #define NOP() __asm__ __volatile__("nop")
26
 #define NOP() __asm__ __volatile__("nop")
27
 
27
 
28
-void spi_init(void);
29
-void spi_write(uint8_t command);
30
-uint8_t spi_read(void);
28
+void spiInit(void);
29
+void spiWrite(uint8_t command);
30
+uint8_t spiRead(void);
31
 
31
 
32
 #endif
32
 #endif
33
 
33
 

+ 9
- 9
src/cc2500.c View File

12
 
12
 
13
 void cc2500ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length) {
13
 void cc2500ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length) {
14
     CS_off;
14
     CS_off;
15
-    spi_write(address);
15
+    spiWrite(address);
16
     for (uint8_t i = 0; i < length; i++) {
16
     for (uint8_t i = 0; i < length; i++) {
17
-        data[i] = spi_read();
17
+        data[i] = spiRead();
18
     }
18
     }
19
     CS_on;
19
     CS_on;
20
 }
20
 }
21
 
21
 
22
 void cc2500WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length) {
22
 void cc2500WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length) {
23
     CS_off;
23
     CS_off;
24
-    spi_write(CC2500_WRITE_BURST | address);
24
+    spiWrite(CC2500_WRITE_BURST | address);
25
     for (uint8_t i = 0; i < length; i++) {
25
     for (uint8_t i = 0; i < length; i++) {
26
-        spi_write(data[i]);
26
+        spiWrite(data[i]);
27
     }
27
     }
28
     CS_on;
28
     CS_on;
29
 }
29
 }
36
 
36
 
37
 void cc2500WriteReg(uint8_t address, uint8_t data) {
37
 void cc2500WriteReg(uint8_t address, uint8_t data) {
38
     CS_off;
38
     CS_off;
39
-    spi_write(address);
39
+    spiWrite(address);
40
     NOP();
40
     NOP();
41
-    spi_write(data);
41
+    spiWrite(data);
42
     CS_on;
42
     CS_on;
43
 }
43
 }
44
 
44
 
46
     uint8_t result;
46
     uint8_t result;
47
     CS_off;
47
     CS_off;
48
     address |= 0x80; // bit 7 =1 for reading
48
     address |= 0x80; // bit 7 =1 for reading
49
-    spi_write(address);
50
-    result = spi_read();
49
+    spiWrite(address);
50
+    result = spiRead();
51
     CS_on;
51
     CS_on;
52
     return result;
52
     return result;
53
 }
53
 }
54
 
54
 
55
 void cc2500Strobe(uint8_t address) {
55
 void cc2500Strobe(uint8_t address) {
56
     CS_off;
56
     CS_off;
57
-    spi_write(address);
57
+    spiWrite(address);
58
     CS_on;
58
     CS_on;
59
 }
59
 }
60
 
60
 

+ 3
- 3
src/spi.c View File

4
 
4
 
5
 #include "spi.h"
5
 #include "spi.h"
6
 
6
 
7
-void spi_init(void) {
7
+void spiInit(void) {
8
     DDRB |= (1 << PB2);  // SI output
8
     DDRB |= (1 << PB2);  // SI output
9
     DDRB &= ~(1 << PB3); // SO input
9
     DDRB &= ~(1 << PB3); // SO input
10
     DDRB |= (1 << PB4);  // SCLK output
10
     DDRB |= (1 << PB4);  // SCLK output
16
     CS_on;
16
     CS_on;
17
 }
17
 }
18
 
18
 
19
-void spi_write(uint8_t command) {
19
+void spiWrite(uint8_t command) {
20
     SCK_off; //SCK start low
20
     SCK_off; //SCK start low
21
     MO_off;
21
     MO_off;
22
 
22
 
38
     MO_on;
38
     MO_on;
39
 }
39
 }
40
 
40
 
41
-uint8_t spi_read(void) {
41
+uint8_t spiRead(void) {
42
     uint8_t result = 0;
42
     uint8_t result = 0;
43
 
43
 
44
     for (uint8_t i = 0; i < 8; i++) {
44
     for (uint8_t i = 0; i < 8; i++) {

Loading…
Cancel
Save