X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=carlfw%2Fsrc%2Fpattern_generator.c;fp=carlfw%2Fsrc%2Fpattern_generator.c;h=7cadb1221c3c26d6232a29916c53bae7c28fe4aa;hb=1a0ab91a746487301a30ecef2b2f95d40527f3da;hp=0000000000000000000000000000000000000000;hpb=195268cae3bb2f462d82dc0178dbca07f0cff706;p=carl9170fw.git diff --git a/carlfw/src/pattern_generator.c b/carlfw/src/pattern_generator.c new file mode 100644 index 0000000..7cadb12 --- /dev/null +++ b/carlfw/src/pattern_generator.c @@ -0,0 +1,57 @@ +/* + * carl9170 firmware - used by the ar9170 wireless device + * + * pattern generator + * + * Copyright 2013 Christian Lamparter + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "carl9170.h" +#include "pattern_generator.h" +#include "fwdsc.h" +#include "timer.h" + +#if defined(CONFIG_CARL9170FW_PATTERN_GENERATOR) + +void pattern_generator(void) +{ + if (fw.phy.state == CARL9170_PHY_ON) { + if (likely(fw.wlan.soft_pattern == NO_PATTERN || + fw.wlan.soft_pattern >= __CARL9170FW_NUM_PATTERNS)) + return; + + const struct pattern_info *pattern = &patterns[fw.wlan.soft_pattern]; + if (pattern->pulses >= fw.wlan.pattern_index) { + fw.wlan.pattern_index = 0; + } + + if (pattern->pulses > fw.wlan.pattern_index) { + const struct pattern_pulse_info *ppi = &pattern->pattern[fw.wlan.pattern_index]; + if (is_after_usecs(fw.wlan.pattern_last, ppi->pulse_interval)) { + fw.wlan.pattern_last = get_clock_counter(); + set(0x1C3BC0, ppi->pulse_pattern); + set(0x1C3BBC, ppi->pulse_mode); + udelay(ppi->pulse_width); + set(0x1C3BBC, 0); + set(0x1C3BC0, 0); + fw.wlan.pattern_index++; + } + } + } +} + +#endif /* CONFIG_CONFIG_CARL9170FW_RADAR */