Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

46 řádky
1.7 KiB

  1. /* Functions to initialize, send, receive over USART
  2. initUSART requires BAUD to be defined in order to calculate
  3. the bit-rate multiplier.
  4. */
  5. #ifndef BAUD /* if not defined in Makefile... */
  6. #define BAUD 9600 /* set a safe default baud rate */
  7. #endif
  8. /* These are defined for convenience */
  9. #define USART_HAS_DATA bit_is_set(UCSR0A, RXC0)
  10. #define USART_READY bit_is_set(UCSR0A, UDRE0)
  11. /* Takes the defined BAUD and F_CPU,
  12. calculates the bit-clock multiplier,
  13. and configures the hardware USART */
  14. void initUSART(void);
  15. /* Blocking transmit and receive functions.
  16. When you call receiveByte() your program will hang until
  17. data comes through. We'll improve on this later. */
  18. void transmitByte(uint8_t data);
  19. uint8_t receiveByte(void);
  20. void printString(const char myString[]);
  21. /* Utility function to transmit an entire string from RAM */
  22. void readString(char myString[], uint8_t maxLength);
  23. /* Define a string variable, pass it to this function
  24. The string will contain whatever you typed over serial */
  25. void printByte(uint8_t byte);
  26. /* Prints a byte out as its 3-digit ascii equivalent */
  27. void printWord(uint16_t word);
  28. /* Prints a word (16-bits) out as its 5-digit ascii equivalent */
  29. void printBinaryByte(uint8_t byte);
  30. /* Prints a byte out in 1s and 0s */
  31. char nibbleToHex(uint8_t nibble);
  32. char nibbleToHexCharacter(uint8_t nibble);
  33. void printHexByte(uint8_t byte);
  34. /* Prints a byte out in hexadecimal */
  35. uint8_t getNumber(void);
  36. /* takes in up to three ascii digits,
  37. converts them to a byte when press enter */