fork download
  1. #include <stdio.h>
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <avr/interrupt.h>
  5. #include <avr/cpufunc.h>
  6.  
  7. #define DDR_SPI DDRB
  8. #define DD_MOSI DDB5
  9. #define DD_MISO DDB6
  10. #define DD_SCK DDB7
  11.  
  12. #include "uart.h"
  13.  
  14. void spi_init(void) {
  15. DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);
  16. SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
  17. }
  18.  
  19. FILE usart0_str = FDEV_SETUP_STREAM(USART0SendByte, USART0ReceiveByte, _FDEV_SETUP_RW);
  20.  
  21. void print_block(uint8_t *block_address, uint16_t length)
  22. {
  23. uint16_t i, j;
  24. uint8_t byte;
  25.  
  26. for(i = 0; i < length / 16; i++)
  27. {
  28. printf("%04x: ", i * 16);
  29.  
  30. for(j = 0; j < 16; j++)
  31. {
  32. printf("%02x", block_address[i * 16 + j]);
  33. }
  34.  
  35. printf(" ");
  36. for(j = 0; j < 16; j++)
  37. {
  38. byte = block_address[i * 16 + j];
  39.  
  40. if ((byte >= 32) && byte <= 126)
  41. printf("%c", byte);
  42. else
  43. printf(".");
  44. }
  45.  
  46. printf("\n");
  47. }
  48. }
  49.  
  50. int main(void) {
  51. //uint8_t i;
  52. uint8_t byte;
  53.  
  54. USART0Init();
  55. stdin=stdout=&usart0_str;
  56.  
  57. _delay_ms(1);
  58. spi_init();
  59. printf("Start\r\n");
  60. byte = 0x00;
  61.  
  62. //for(i = 0; i < 10; i++){
  63. SPDR = 0xFF;
  64. while(!(SPSR & (1<<SPIF))){
  65. byte++;
  66. }
  67.  
  68. printf("%d\r\n", byte);
  69. byte = 0x00;
  70.  
  71. SPDR = 0xFF;
  72. while(!(SPSR & (1<<SPIF))){
  73. byte++;
  74. }
  75.  
  76. printf("%d\r\n", byte);
  77. byte = 0x00;
  78.  
  79. // }
  80.  
  81. printf("Stop\n");
  82.  
  83.  
  84. while (1) {
  85. _NOP();
  86. }
  87.  
  88. return 1;
  89. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:20: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
                    ^
compilation terminated.
stdout
Standard output is empty