Reversed bit ordering to make more sense
This commit is contained in:
@@ -89,12 +89,12 @@ uint16_t mfm_encode_bit(uint8_t b) {
|
|||||||
|
|
||||||
if (b == 0x80) {
|
if (b == 0x80) {
|
||||||
last_bit = 1;
|
last_bit = 1;
|
||||||
return 0b1000000000000000;
|
return 0b01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (last_bit == 0) {
|
if (last_bit == 0) {
|
||||||
return 0b0100000000000000;
|
return 0b10;
|
||||||
} else {
|
} else {
|
||||||
last_bit = 0;
|
last_bit = 0;
|
||||||
return 0b00;
|
return 0b00;
|
||||||
@@ -109,7 +109,7 @@ uint16_t mfm_encode(uint8_t b) {
|
|||||||
//Serial.println(b, HEX);
|
//Serial.println(b, HEX);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
out >>= 2;
|
out <<= 2;
|
||||||
//Serial.println(b, BIN);
|
//Serial.println(b, BIN);
|
||||||
out |= mfm_encode_bit(b & 0x80);
|
out |= mfm_encode_bit(b & 0x80);
|
||||||
b <<= 1;
|
b <<= 1;
|
||||||
@@ -155,7 +155,8 @@ void loop() {
|
|||||||
header_crc = 0xFFFF;
|
header_crc = 0xFFFF;
|
||||||
header_crc = crc16(0xA1, header_crc);
|
header_crc = crc16(0xA1, header_crc);
|
||||||
uint16_t sync = mfm_encode(0xA1);
|
uint16_t sync = mfm_encode(0xA1);
|
||||||
sync &= 0b1111101111111111;
|
//sync &= 0b1111101111111111;
|
||||||
|
sync &= 0b1111111111011111;
|
||||||
|
|
||||||
pio->txf[sm] = sync;
|
pio->txf[sm] = sync;
|
||||||
csend(0xFE);
|
csend(0xFE);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public start:
|
|||||||
|
|
||||||
.wrap_target
|
.wrap_target
|
||||||
PULL noblock
|
PULL noblock
|
||||||
|
OUT NULL, 16
|
||||||
|
|
||||||
SET Y,6
|
SET Y,6
|
||||||
loop:
|
loop:
|
||||||
@@ -19,7 +20,7 @@ loop:
|
|||||||
OUT PINS,1 [14]
|
OUT PINS,1 [14]
|
||||||
SET PINS,0 [14]
|
SET PINS,0 [14]
|
||||||
OUT PINS,1 [14]
|
OUT PINS,1 [14]
|
||||||
SET PINS,0 [12]
|
SET PINS,0 [11]
|
||||||
|
|
||||||
.wrap
|
.wrap
|
||||||
|
|
||||||
@@ -30,6 +31,8 @@ static inline void datastream_program_init(PIO pio, uint sm, uint offset) {
|
|||||||
pio_gpio_init(pio, 12);
|
pio_gpio_init(pio, 12);
|
||||||
pio_sm_set_consecutive_pindirs(pio, sm, 12, 1, true);
|
pio_sm_set_consecutive_pindirs(pio, sm, 12, 1, true);
|
||||||
pio_sm_config c = datastream_program_get_default_config(offset);
|
pio_sm_config c = datastream_program_get_default_config(offset);
|
||||||
|
sm_config_set_out_shift(&c, false, false, 0);
|
||||||
|
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
|
||||||
sm_config_set_clkdiv(&c, 1.0);
|
sm_config_set_clkdiv(&c, 1.0);
|
||||||
sm_config_set_out_pin_base(&c, 12);
|
sm_config_set_out_pin_base(&c, 12);
|
||||||
sm_config_set_out_pin_count(&c, 1);
|
sm_config_set_out_pin_count(&c, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user