srecord: stm32.h Source File

srecord 1.65.0

Loading...
Searching...
No Matches
stm32.h
Go to the documentation of this file.
1//
2// srecord - manipulate eprom load files
3// Copyright (C) 2012 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify it
6// under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or (at your
8// option) any later version.
9//
10// This program is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13// for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18//
19// From: Hendrik Beijeman <hbeyeman@gmail.com>
20// To: pmiller@opensource.org.au
21// Subject: Re: patch for srecord 1.59
22// Date: Sat, 05 May 2012 06:26:02 +0200 (05/05/12 14:26:02)
23//
24// I hereby formally assign all copyright to the author of srecord,
25// Peter Miller.
26//
27
28#ifndef SRECORD_STM32_H
29#define SRECORD_STM32_H
30
31#include <stddef.h>
32
33namespace srecord
34{
35
36/**
37 * The stm32 class is used to represent the running value of a 32-bit
38 * cyclic redundancy check of series of bytes, for the STM32 series of
39 * microcontrollers.
40 * http://www.st.com/
41 */
42 class stm32
43{
44public:
45 /**
46 * The destructor.
47 */
48 virtual ~stm32();
49
50 /**
51 * The default constructor.
52 */
53 stm32();
54
55 /**
56 * The copy constructor.
57 */
58 stm32(const stm32 &);
59
60 /**
61 * The assignment operator.
62 */
63 stm32 &operator=(const stm32 &);
64
65 /**
66 * The get method is used to obtain the running value of the cyclic
67 * redundancy check.
68 */
69 unsigned long get(void) const;
70
71 /**
72 * The next method is used to advance the state by one byte.
73 */
74 void next(unsigned char c);
75
76 /**
77 * The nextbuf method is used to advance the state by a series of bytes.
78 */
79 void nextbuf(const void *data, size_t data_size);
80
81 /**
82 * Word size on the STM32
83 */
84 static const size_t wordsize = 4;
85
86private:
87 /**
88 * Run the generator on the filled buffer. The generator assumes
89 * the incomming bytestream is in little-endian order, which is safe
90 * considering this is for the STM32F series MPUs.
91 */
92 void generator(void);
93
94 /**
95 * The state instance variable is used to remember the running
96 * value of the 32-bit cyclic redundancy check.
97 */
98 unsigned long state;
99
100 /**
101 * Current counter of the byte feeding
102 */
103 size_t cnt;
104
105 /**
106 * Buffer the incomming stream to build a word to feed to the
107 * CRC generator.
108 */
109 unsigned char buf[wordsize];
110};
111
112};
113
114// vim: set ts=8 sw=4 et :
115#endif // SRECORD_CRC32_H
srecord::stm32::get
unsigned long get(void) const
The get method is used to obtain the running value of the cyclic redundancy check.
srecord::stm32::nextbuf
void nextbuf(const void *data, size_t data_size)
The nextbuf method is used to advance the state by a series of bytes.
srecord::stm32::operator=
stm32 & operator=(const stm32 &)
The assignment operator.
srecord::stm32::next
void next(unsigned char c)
The next method is used to advance the state by one byte.
srecord::stm32::stm32
stm32()
The default constructor.
srecord::stm32::wordsize
static const size_t wordsize
Word size on the STM32.
Definition stm32.h:84
srecord::stm32::stm32
stm32(const stm32 &)
The copy constructor.
srecord::stm32::~stm32
virtual ~stm32()
The destructor.
srecord
Definition adler16.h:25