Microprocessor and peripheral 2 assignments for AUTH
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
2.1 KiB

  1. /*!
  2. * \file deque08.h
  3. * \brief
  4. * This file provides double ended queue capability based on a ring buffer
  5. *
  6. * Copyright (C) 2014 Houtouridis Christos <houtouridis.ch@gmail.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as
  10. * published by the Free Software Foundation, either version 3
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef __deque08_h__
  23. #define __deque08_h__
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include "driver_types.h"
  28. #include <string.h>
  29. typedef struct {
  30. byte_t *m; /*!< pointer to queue's buffer */
  31. iterator_t capacity; /*!< queue's max item capacity */
  32. iterator_t items; /*!< current item count */
  33. iterator_t f, r; /*!< queue iterators */
  34. }deque08_t;
  35. /*
  36. * ============= PUBLIC EE API =============
  37. */
  38. /*
  39. * Link and Glue functions
  40. */
  41. void deque08_link_buffer (deque08_t *q, byte_t* buf);
  42. /*
  43. * Set functions
  44. */
  45. void deque08_set_capacity (deque08_t *q, size_t capacity);
  46. /*
  47. * User Functions
  48. */
  49. int deque08_is_full (deque08_t *q);
  50. int deque08_is_empty (deque08_t *q);
  51. int deque08_size (deque08_t *q);
  52. void deque08_flush (deque08_t *q);
  53. void deque08_init (deque08_t *q);
  54. int deque08_push_front (deque08_t *q, byte_t b);
  55. int deque08_pop_front (deque08_t *q, byte_t *b);
  56. int deque08_push_back (deque08_t *q, byte_t b);
  57. int deque08_pop_back (deque08_t *q, byte_t *b);
  58. int deque08_back (deque08_t *q, byte_t *b);
  59. int deque08_front (deque08_t *q, byte_t *b);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif //#ifndef __deque08_h__