We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1c401ec commit 2921b43Copy full SHA for 2921b43
mfrc522.py
@@ -5,6 +5,9 @@
5
6
class MFRC522:
7
8
+ GAIN_REG = 0x26
9
+ MAX_GAIN = 0x07
10
+
11
OK = 0
12
NOTAGERR = 1
13
ERR = 2
@@ -189,8 +192,10 @@ def init(self):
189
192
self._wreg(0x2C, 0)
190
193
self._wreg(0x15, 0x40)
191
194
self._wreg(0x11, 0x3D)
195
+ self.set_gain(self.MAX_GAIN)
196
self.antenna_on()
197
198
199
def reset(self):
200
self._wreg(0x01, 0x0F)
201
@@ -258,6 +263,13 @@ def halt_a(self):
258
263
def stop_crypto1(self):
259
264
self._cflags(0x08, 0x08)
260
265
266
+ def set_gain(self, gain):
267
+ assert gain <= self.MAX_GAIN
268
+ # clear bits
269
+ self._cflags(self.GAIN_REG, 0x07<< 4)
270
+ # set bits according to gain
271
+ self._sflags(self.GAIN_REG, gain << 4)
272
261
273
def read(self, addr, into = None):
262
274
buf = self.regBuf
275
buf[0]=0x30
0 commit comments